[OJ]1009:抛硬币

2019-1-12 写技术

Description James得到了一堆有趣的硬币,于是决定用这些硬币跟朋友们玩个小游戏。在一个N行M列的表格上,每一个第i行第j列的格子上都放有一枚James的硬币,抛该硬币正面朝上的概率为Pij,所有抛硬币事件两两之间是相互独立的。 现在,玩家在M列硬币中,从每一列里各选择1枚,共M枚,构成一组。如此重复选择N组出来,且保证被选择过的硬币不能再选。选好组之后,每组的M枚硬币各抛一次,如果都是正面朝上,则该组胜利,总分赢得1分;否则该组失败,总分不加也不减。请问,如果让你自行选择硬币的分组,游戏总得分的数学期望的最大值是多少? ...

阅读全文>>

标签: C

评论(0) 浏览(1118)

[OJ]1008:

2019-1-12 写技术

Description A Horcrux is an object in which a Dark wizard or witch has hidden a fragment of his or her soul for the purpose of attaining immortality. Constructing a Horcrux is considered Dark magic of the foulest, most evil kind, as it violates laws of nature and morality, and requi...

阅读全文>>

标签: C

评论(0) 浏览(984)

[OJ]1005:Binary Search Tree analog

2019-1-11 写技术

Input The first integer of the input is T, the number of test cases. Each test case has two lines. The first line contain an integer N,(1<=N<=1000), the number of numbers need to be inserted into the BST. The second line contain N integers separated by space, each integer is in the...

阅读全文>>

标签: C

评论(0) 浏览(1056)

[OJ]1004:Xi and Bo

2019-1-11 写技术

Description Bo has been in Changsha for four years. However he spends most of his time staying his small dormitory. One day he decides to get out of the dormitory and see the beautiful city. So he asks to Xi to know whether he can get to another bus station from a bus station. Xi is n...

阅读全文>>

标签: C

评论(0) 浏览(1375)

[OJ]1003:UC Browser

2019-1-10 写技术

You can get 10 experiences after using UC Browser one day in a row, 20 experiences for two days in a row, 30 experiences for three days in a row, 40 experiences for four days in a row, 50 experiences for five days in a row. If you use UC Browser six days in a row, the experiences you can g...

阅读全文>>

标签: C

评论(0) 浏览(1112)

[C]文件定宽换行工具

2018-3-30 写技术

弄了几篇英语文章,想要在Linux下阅读,可是发现没有换行,每一段都是从左到右一整行,于是写下这个小工具,实现自动换行: #include <stdio.h> #include <stdlib.h> #include <string.h> void main( int argc, char *argv[]){ FILE *fp_in = 0; FILE *fp_out = 0; char str[1024]={0}; char file_out[512]={0}; int len = 0; int i = -1; ...

阅读全文>>

标签: C

评论(0) 浏览(1176)

[c]scanf输入字符

2018-1-18 写技术

如果用scanf("%c",&ch),那么程序不会忽略为了输入而按下的回车键操作,而是认为回车键是后续操作而继续相应;而scanf(" %c", &c)在%c之前空格会告诉scanf忽略前面的空行,而等待第一个非空行元素读入其中。

阅读全文>>

标签: C

评论(0) 浏览(1175)

[C]Example of websockets server

2017-10-23 写技术

#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <openssl/sha.h> #include <openssl/pem.h> #include <openssl/bio.h> #incl...

阅读全文>>

标签: C

评论(0) 浏览(1326)

[C]Safari对websocket的支持及websocket版本问题的解决记

2017-7-11 写技术

昨天有人反应苹果手机不能访问我的物联网项目,我大惊,立马开始分析。 发现果然苹果端的safari连接websocket失败了。但是我确信之前一直用着好好的。可能是贱贱的A厂悄悄变更了某些软件吧,没办法,谁让世人都称他是老大,谁让你们那么多人没有iPhone不行呢。我只好认为我自己的服务器有问题了。 于是检查服务器的日志,发现websocket的握手过程显示协议错误。 那么我抓包分析下safari与其他浏览器的行为有什么不一样吧: 这是Google: Sec-WebSocket-Key:GX2sEWmKLhgktWvslt8xxw== Sec-WebSocket...

阅读全文>>

标签: ubuntu C linux

评论(3) 浏览(5202)

[c]数组与字符串长度

2017-3-16 写技术

来看看在C语言里面字符串与数组的长度怎么取得吧,不多说,上代码: char *str="abcdefg"; char strq[10] = "abcdefg"; printf("%d %d\n", sizeof(str), strlen(str)); printf("%d %d\n", sizeof(strq), strlen(strq)); 结果是: 8        7 10       &...

阅读全文>>

标签: C

评论(0) 浏览(1249)

Powered by anycle 湘ICP备15001973号-1