题意:
给两个盒子里面都有n个糖果,每次从第一个盒子里拿糖果的概率是p,另一个是1-p
问当拿完一个盒子时,另一个盒子还有多少糖果的期望。
其中有一点就是,当她打开盒子发现是空的时候 会去打开另一个盒子在同一天。
思路:
期望公式很好推:
但是推完就会出现各种溢出问题
所以要用对数优化
代码:
#include"cstdlib"
#include"cstdio"
#i...
分类:
其他好文 时间:
2014-10-30 13:36:20
阅读次数:
174
mac升级之后 php 被自动升级,导致php环境破坏
所以 需要修复如下几点
1.
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /usr/include
注意红色的...
分类:
Web程序 时间:
2014-10-30 13:35:38
阅读次数:
222
read和write
#include
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
参数:
fd: 文件描述符
buf:数据缓冲区,用于保存要从fd读取或写入的数据
count:输入/写入的数据最大字节数。(实际读取或...
分类:
其他好文 时间:
2014-10-30 13:33:52
阅读次数:
238
题目链接:点击打开链接
#include
#include
using namespace std;
typedef long long ll;
ll re;
vector p;
void dfs(int dep, int g) {
if (dep == 0)
return ;
if (p[dep-1] == 1) {
re += (dep-1) * (1...
分类:
其他好文 时间:
2014-10-30 13:32:20
阅读次数:
159
题目大意:给出一个地图,有两种点,P点可以站人,H点不能站人。每放一个人就会对他上下左右各两个格子产生影响,产生影响的格子不能放人。问最多能放多少个人。
思路:数据范围指引解题的方向。题中给出M
最后是如果m
CODE:
#include
#include
#include
#include
using namespace std;
int m,n;
ch...
分类:
其他好文 时间:
2014-10-30 13:32:09
阅读次数:
275
题目链接:点击打开链
#include
#include
#include
using namespace std;
typedef long long ll;
vector s;
int main() {
int n, k;
while (~scanf("%d%d", &n, &k)) {
s.clear();
int sum = 0, cnt = 0;
for(int ...
分类:
其他好文 时间:
2014-10-30 13:31:37
阅读次数:
228
man poll:NAME poll, ppoll - wait for some event on a file descriptorSYNOPSIS #include int poll(struct pollfd *fds, nfds_t nfds, int...
分类:
系统相关 时间:
2014-10-30 13:31:09
阅读次数:
220
题目链接:点击打开链接
题意:
给定一个数,重新排列这个数的各个位置使得
1、无前导0
2、能被11整除
问:
有多少种组合方法
#include
#include
#include
using namespace std;
typedef long long ll;
const int mod = 1000000000 + 7;
const int N = 100+2...
分类:
其他好文 时间:
2014-10-30 13:30:41
阅读次数:
180
题意:求fibonacci数列第n项 1 #include "iostream" 2 #include "vector" 3 #include "cstring" 4 using namespace std; 5 6 typedef unsigned long int ULL; 7 typedef....
分类:
其他好文 时间:
2014-10-30 13:29:54
阅读次数:
246
1 #include "iostream" 2 #include "vector" 3 #include "cstring" 4 using namespace std; 5 6 typedef unsigned long int ULL; 7 typedef vector vec; 8 typ.....
分类:
其他好文 时间:
2014-10-30 13:21:07
阅读次数:
199