
数论
文章平均质量分 72
lp_opai
我没有时间写一封简短的信,所以我写了一封长的。
展开
-
hdu 4908 BestCoder Sequence
# include # include using namespace std;int main(){ int n,m,i,sum,cot,flag,j; int map[80040]; int a[40010]; int ans1; int ans2; while(~scanf("%d%d",&n,&m)) { ans1=ans2=40010; memset(map原创 2014-08-04 11:12:25 · 794 阅读 · 0 评论 -
hdu 4704 Sum (费马小定理+快速幂)
//(2^n-1)%mod//费马小定理:a^n ≡ a^(n%(m-1)) * a^(m-1)≡ a^(n%(m-1)) (mod m)# include # include # include # define mod 1000000007using namespace std;__int64 pow(__int64 n){ __int64 p=1,q=2; w原创 2014-08-05 21:03:02 · 817 阅读 · 0 评论 -
HDU 3037 Saving Beans (Lucas定理)
/*求在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 20:23:00 · 1117 阅读 · 0 评论 -
hdu1573 X问题(中国剩余定理解的个数)
/*求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod a[i] = b[i], … (0 < a[i] <= 10)。中国剩余定理解的个数最终解出一个答案为al,循环为b1*/# include # include # include using names原创 2015-09-14 18:32:11 · 598 阅读 · 0 评论