摘要: 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) 编辑
摘要: 就是在能取大的尽量取大的 比如在可以用二分查找的方法; 有时间限制的题目,可以从时间的最后面的开始分配,尽量不浪费; 有多种解决方法的,用多种解决方法算出来,比较哪种更好; 重点就是一个字“大” 阅读全文
posted @ 2018-07-23 14:29 一无所知小白龙 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。 Input 数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 include include include include include def 阅读全文
posted @ 2018-07-23 14:25 一无所知小白龙 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 一般数据比较大的时候,让你找满足条件的最小值中的最大值,或者最大的最小值可以用二分; 设下限为0,上限的最大的条件; 最后求出来的就是所需要的值; 如果K是1,也就是题目要求的是整数的时候,要加上 因为这时可能会有特殊的没法考虑,加上这个才能确定真正的答案! 还有一个stl函数binary_sear 阅读全文
posted @ 2018-07-23 12:15 一无所知小白龙 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 给出组合数C(n,m), 表示从n个元素中选出m个元素的方案数。例如C(5,2) = 10, C(4,2) = 6.可是当n,m比较大的时候,C(n,m)很大!于是xiaobo希望你输出 C(n,m) mod p的值! Input 输入数据第一行是一个正整数T,表示数据组数 (T include i 阅读全文
posted @ 2018-07-23 12:05 一无所知小白龙 阅读(328) 评论(0) 推荐(0) 编辑