HDU Game Theory】的更多相关文章

5795 || 3032 把x个石子的堆分成非空两(i, j)或三堆(i, j, k)的操作->(sg[i] ^ sg[j])或(sg[i] ^ sg[j] ^ sg[k])是x的后继 #define pron "hdu5795" #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; ]…
6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题] 代码: //1012-6343-数学 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<bitset&g…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2685 题意:求gcd(a^m - 1, a^n - 1) mod k 思路:gcd(a^m - 1, a^n - 1) = a^gcd(m, n) - 1 code: #include <stdio.h> int gcd(int a, int b) { return !b ? a : gcd(b, a%b); } int mod_pow(int a, int x, int mod) { int t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem DescriptionThere is a complete graph containing n vertices, the weight of the i-th vertex is wi.The length…
这个分类怎么觉得这么水呢.. 这个分类做到尾的模板集: //gcd int gcd(int a,int b){return b? gcd(b, a % b) : a;} //埃氏筛法 O(nlogn) int prime[MAX_N]; bool is_prime[MAX_N];//i是不是素数 int sieve() { ; ; i <= n; i++) is_prime[i] = true; is_prime[] = is_prime[] = false; ; i <= n; i++) {…
题目链接 根据公式 \[ gcd(a^m-1, a^n-1) = a^{gcd(m, n)}-1 \] 就可以很容易的做出来了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex> #include <cmath> #include <map…
贪心. 每次找到后面最近的一个能连边的连边. #include <bits/stdc++.h> using namespace std; ; int T,n,k; ],b[],u[]; int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); ; ;i<=n;i++) { scanf("%d",&a[i]); ) cnt++; } k=; ;i--…
大意: 求重复$k$次的子串个数 枚举重复长度$i$, 把整个串分为$n/i$块, 如果每块可以$O(1)$计算, 那么最终复杂度就为$O(nlogn)$ 有个结论是: 以$j$开头的子串重复次数最大为$1+\lfloor\frac{lcp(j,j+i)}{i}\rfloor$ 先特判掉$k=1$的情况, 然后枚举每个块开头的位置, 计算出$lcp$的值$p$, 由于$k>1$, 合法位置的$lcp$值至少要跨越一个块, 可以得到 若$p\ge ki-1$, 那么这个块内所有点都合法 若$k(i…
Lost's revenge Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2262    Accepted Submission(s): 565 Problem Description Lost and AekdyCoin are friends. They always play "number game"(A bori…
Count the string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8845    Accepted Submission(s): 4104 Problem Description It is well known that AekdyCoin is good at string problems as well as n…