06 2020 档案
摘要:A. Donut Shops There are two rival donut shops. The first shop sells donuts at retail: each donut costs a dollars. The second shop sells donuts only i
阅读全文
摘要:单模式串匹配 KMP算法 推理过程见详解 . #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009 #
阅读全文
摘要:并查集代码真是又短又有趣,易于理解见详解 . int n,m,k; int p[MS],tr[MS],fa[MS]; void init(){ for(int i=1;i<=n;i++) fa[i] = i; } int find(int x){ if(x == fa[x]) return x; e
阅读全文
摘要:单点更新 区间查询 直接利用树状数组存储原数组 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009
阅读全文
摘要:递归 #include <bits/stdc++.h> #define LL long long #define Pi acos(-1.0) #define INF 2147483646 #define eps 1e-9 #define MS 100009 #define mss 17 using
阅读全文
摘要:A. Shovels and Swords Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels a
阅读全文
摘要:直接求解 LL factor(LL x){ LL cnt = 0; for(int i=1;i<=sqrt(x);i++){ if(x%i==0){ if(x/i == i) cnt += i; // ex: 9 = 3 * 3 else cnt += i + x/i; } } return cnt
阅读全文
摘要:什么是数独 数独(shù dú)是源自18世纪瑞士的一种数学游戏。是一种运用纸、笔进行演算的逻辑游戏。玩家需要根据9×9盘面上的已知数字,推理出所有剩余空格的数字,并满足每一行、每一列、每一个粗线宫(3*3)内的数字均含1-9,不重复 [1] 。 数独盘面是个九宫,每一宫又分为九个小格。在这八十一格
阅读全文
摘要:判断素数 int is_prime(int n) { if(n==1)return 0; for(int i=2;i*i<=n;i++){ if(n%i==0) return 0; } return 1; } 普通筛 int p[MS]; memset(p,0,sizeof p); for(int
阅读全文
摘要:公式 代码模拟公式计算 例:C(7,3)则循环三次每次分别为 5 / 1 , 5 * 6 / 1 * 2 , 5 * 6 * 7 / 1 * 2 * 3 C(n,m) #define LL long long LL C(LL n,LL m) // n为下标 m为上标 { LL k,sum = 1;
阅读全文
摘要:inline LL read(){ LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();} while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
阅读全文
摘要:#define LL long long LL qmul(LL a,LL b,LL mod){ LL ans = 0; for(;b;b>>=1){ if(b&1) ans = (ans+a)%mod; a = a*2%mod; } return ans; }
阅读全文
摘要:循环 #define LL long long LL qpow(LL n,LL m){ LL ans = 1%mod; while(m>0){ if(m&1) ans = ans*n%mod; n = n*n%mod; m >>= 1; } return ans; } 递归 #define LL l
阅读全文

浙公网安备 33010602011771号