此处省略引经据典。 (为了方便叙述,x=(a1,a2,a3)(b1,b2,b3)表示 x≡a1(mod b1) x≡a2(mod b2) x≡a3(mod b3) ) 举个栗子。 栗子 求x=(2,3,2)(3,5,7)的最小正整数解。 考虑转化为三个子问题。 思考后可得 x=(2*(1,0,0)( ...
分类:
其他好文 时间:
2018-03-26 22:28:07
阅读次数:
281
Discription There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees. Find the value of the sum modulo 109?+ ...
分类:
其他好文 时间:
2018-03-11 20:53:15
阅读次数:
194
LL exGcd(LL a,LL b,LL &x,LL &y) { if(!b) { x=1,y=0; return a; } LL d=exGcd(b,a%b,y,x); y=y-a/b*x; return d; } LL chineseRemainder(LL n,LL *a,LL *b)/// ...
分类:
其他好文 时间:
2018-03-11 19:16:35
阅读次数:
172
题目描述 两青蛙会相遇的条件[(x-y)+k(m-n)]%l=0 令a=m-n,b=l,c=x-y,所以(c+k*a)%b=0 -> aX+bY=c 方程有解,当且仅当c%Gcd(a,b)=0 令r=Gcd(a,b) 为什么(X*(c/r)%(b/r)+b/r)%(b/r)为最小解? 目标解aX+b ...
分类:
其他好文 时间:
2018-03-08 22:07:12
阅读次数:
202
扩展欧几里得算法 求逆元就不说了。 ax+by=c 这个怎么求,很好推。 设d=gcd(a,b) 满足d|c方程有解,否则无解。 扩展欧几里得求出来的解是 x是 ax+by=gcd(a,b)的解。 对于c的话只需要x*c/gcd(a,b)%(b/d)即可,因为b/d的剩余系更小。 为什么这样呢? 设 ...
分类:
其他好文 时间:
2018-03-08 00:13:23
阅读次数:
202
【题目背景】 露娜的好朋fu友qin猪哥哥是一个屌丝科学家,他发明出了一个可以进行空间跳跃的机器,露娜将作为第一个乘客进行时空跳跃之旅。她将地点定位于佩奇的家。嗖! 露娜来到佩奇的家中,佩奇一家热情地招待了她,她在佩奇家愉快地玩耍,这期间还学会了花样跳泥坑,种恐龙。时光荏苒,很快到了露娜返程的日子。 ...
分类:
其他好文 时间:
2018-03-04 23:51:39
阅读次数:
241
#include using namespace std; typedef long long ll; ll a[500],r[500],k; ll gcd(ll a,ll b){ while(b!=0){ ll t=a; a=b; b=t%b; } return a; } ll lcm(ll a,... ...
分类:
其他好文 时间:
2018-03-04 18:11:10
阅读次数:
131
题解:中国剩余定理 通解:ans=a[i]*M[i]*Inv(M[i],m[i])+k*M 注意window与linux下读入输出差异 ...
分类:
其他好文 时间:
2018-02-25 20:33:35
阅读次数:
182
若有以下两个同余方程 x ≡ a1 mod n1 x ≡ a2 mod n2 x= n1*k1+a1 = n2*k2+a2 ∴ n1*k1 = n2*k2+a2-a1 ∴ n1*k1 ≡ a2-a1 mod n2 由扩展欧几里得定理得,同余方程有解的条件是 gcd(n1,n2) | (a2-a1) ...
分类:
其他好文 时间:
2018-02-22 16:42:13
阅读次数:
134
http://acm.hdu.edu.cn/showproblem.php?pid=5446 求C(n,m)%(p1p2…pk)的值,其中pi均为质数。 参考:https://www.cnblogs.com/linyujun/p/5199684.html 预备知识: 1.Lucas定理(图片来自百科 ...
分类:
其他好文 时间:
2018-02-21 17:47:03
阅读次数:
122