Mario and Mushrooms
一道数学题,和pzc推了差不多一小时的式子,结果还是错了OTZ,遂看题解
然后发现这题其实就是直接把Raney引理套一套就行了(Raney引理又是什么神仙???)
Raney引理:
设整数序列A={Ai,i=1,2,…,N},且部分和为Sk=A1+,…,+Ak,序列中的所有的数字之和为Sn=1;则在A的N个循环表示中,有且仅有一个序列B,满足B的任意部分和Si均大于零。
一篇文章:
HDOJ4105和raney引理
所以当时为什么不直接打表
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <list> #include <set> #include <map> #include <cctype> #include <string> #include <queue> #define debug printf("debugn") #define mst(a,b) memset(a,b,sizeof(a)) #define INF 0x3f3f3f3f const int maxn=1e5+5; using namespace std; typedef long long ll; typedef unsigned long long ull; int () { int t; cin>>t; int kase=0; while(t--) { double m,k; cin>>m>>k; double ans=1/(m*k+k+1); printf("Case #%d: %.8lfn",++kase,ans); } return 0; }
|
附:自己推出来的错误式子,留个纪念
begin{equation}
frac{frac{k(k+1)m}{2}}{C_{km+1+k}^{k}}
end{equation}
近期评论