摘要:
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2685思路:gcd(A^m-B^m,A^n-B^n)= A^gcd(m,n) - B^gcd(m,n) 这里特殊情况B=1#include #include #include #include #include using namespace std;long long gcd(long long a,long long b){ if(b==0) return a; return gcd(b,a%b);}long long Pow(long long a,long long b... 阅读全文
摘要:
题目:http://poj.org/problem?id=2891思路:扩展欧几里得#include #include #include #include #include using namespace std;#define maxn 100010int n;long long a[maxn],b[maxn];long long exgcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; y=0; return a; } else ... 阅读全文
摘要:
题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=507思路:呵呵 三层一层一层迭代求出循环节。#include #include #include #include #include using namespace std;// 1e9+7// 222222224// 183120int main(){ long long a=0,b=1; long long mod=222222224; long long ans=1; long long c=(3*b+a)%mod; a=b; b=c;... 阅读全文