解题思路:
直接求C(n+m , m) % p , 因为n , m ,p都很大,所以要用Lucas定理来解决大组合数取模的问题。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#de...
分类:
其他好文 时间:
2014-10-17 11:54:26
阅读次数:
185
3523 - Knights of the Round TableTime limit: 4.500 secondsBeing a knight is a very attractive career: searching for the Holy Grail, saving damsels in ...
分类:
其他好文 时间:
2014-10-11 02:03:54
阅读次数:
557
题目链接题意:给出n*n的网格,有且只有一个K(孙悟空)和一个T(唐僧),最多有m把钥匙,最多5条蛇,每走一格的时间为1,走到蛇的格子(杀蛇时间为1)的时间为2,取钥匙要按照顺序来,问能救到唐僧,如果可以输出最短时间。分析:
分类:
其他好文 时间:
2014-10-10 21:33:24
阅读次数:
160
Problem Description《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en...
分类:
其他好文 时间:
2014-10-09 23:30:31
阅读次数:
251
Android设备有两种文件存储区域: 内部存储和外部存储 ("internal" and "external" storage)。 这名字来自早期Android,那时大多数Android设备提供两种存储方式:内置的非易失的内存(内部存储)和可移动的存储例如micro SD卡...
分类:
移动开发 时间:
2014-10-07 01:56:52
阅读次数:
276
Chapter 18 Saving, Loading, and Application State1. Archiving is one of the most common ways of persisting model objects on iOS. Archiving an object i...
分类:
移动开发 时间:
2014-10-04 00:03:55
阅读次数:
286
If you have a relatively small collection of key-values that you'd like to save, you should use the SharedPreferences APIs.
ASharedPreferences object
points to a file containing key-value pairs an...
分类:
其他好文 时间:
2014-10-01 02:51:10
阅读次数:
232
Android uses a file system that's similar to disk-based file systems on other platforms. This lesson describes how to work with the Android file system to read and write files with the FileAPIs....
分类:
其他好文 时间:
2014-10-01 02:01:01
阅读次数:
339
直接lucas降到10w以内搞组合数
#include
#include
typedef __int64 LL;
LL f[110010];
LL pow(LL a, LL b, LL c)
{
LL ans = 1;
while(b)
{
if(b&1)
ans = (ans*a) % c;
b >>= 1;
a = (a*a) % c;
}
return an...
分类:
其他好文 时间:
2014-09-28 21:49:55
阅读次数:
216
/*求在n棵树上摘不超过m颗豆子的方案,结果对p取模。
求C(n+m,m)%p。
因为n,m很大,这里可以直接套用Lucas定理的模板即可。
Lucas(n,m,p)=C(n%p,m%p,p)*Lucas(n/p,m/p,p); ///这里可以采用对n分段递归求解,
Lucas(x,0,p)=1;
将n,m分解变小之后问题又转换成了求C(a/b)%p。
而C(a,b) =a! / ( b! *...
分类:
其他好文 时间:
2014-09-26 22:58:09
阅读次数:
176