摘要: 求a^b(%mod) 如果是接近1e18的数字的快速幂,则会爆long long,这就要用快速乘; 阅读全文
posted @ 2018-07-24 20:48 一无所知小白龙 阅读(138) 评论(0) 推荐(0) 编辑
摘要: The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lovers Walk passing 阅读全文
posted @ 2018-07-24 18:15 一无所知小白龙 阅读(167) 评论(0) 推荐(0) 编辑
摘要: The Farey Sequence Fn for any integer n with n = 2 is the set of irreducible rational numbers a/b with 0 include include include include include defin 阅读全文
posted @ 2018-07-24 17:42 一无所知小白龙 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 1.欧几里得原理是辗转相除法,用来求最大公约数的; 2.拓展欧几里得原理,可以用来解二元一次方程:A X+B Y=C; 模板 (返回值是gcd(a,b)) 因为用的是A X+B Y=gcd(A,B),所以结果x,y要乘上 c/gcd(a,b)!!!!! int ans=exgcd(int a,int 阅读全文
posted @ 2018-07-24 11:05 一无所知小白龙 阅读(376) 评论(0) 推荐(0) 编辑
摘要: n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (la 阅读全文
posted @ 2018-07-23 20:29 一无所知小白龙 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 垃圾版本 对从2到n 1取模,不为0则是素数,O(N) bool judge(ll n) { if(n==2||n==3) return true; for(int i=2;i =1) if (y&1) t=(t+x)%mo; return t; } ll modular_exp(ll num,ll 阅读全文
posted @ 2018-07-23 18:47 一无所知小白龙 阅读(428) 评论(0) 推荐(0) 编辑
摘要: 欧拉公式是用来求n个数中与n互质的数的个数 方法1 直接法套公式 A(n)=n (1 1/v[0]) (1 1/v[1])···(1 1/v[v.size() 1]) 先分解n然后边分解边乘 方法二 用筛法 define Max 1000001 int euler[Max]; euler[1]=1; 阅读全文
posted @ 2018-07-23 17:14 一无所知小白龙 阅读(974) 评论(0) 推荐(0) 编辑
摘要: 用来求关于与n不互质的 模板 先把n拆开 容斥模板 int sum; for(int i=1;i 阅读全文
posted @ 2018-07-23 17:00 一无所知小白龙 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said to be coprime 阅读全文
posted @ 2018-07-23 16:03 一无所知小白龙 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 假设有题目(A/B)%mod,但是数据很大的时候,不好计算或者题目没有直接给A,就可以用逆元 因为是不存在(A%mod /B%mod)%mod的,所有引入逆元; 求A的逆元X:A X=1%mod; 方法一:如果mod是一个质数,可以用快速幂求,X=pow(A,mod 2,mod); 方法二:欧几里得 阅读全文
posted @ 2018-07-23 15:13 一无所知小白龙 阅读(428) 评论(0) 推荐(0) 编辑