As rich as Crassus 题目链接 题目描述 Crassus, the richest man in the world, invested some of his money with the Very Legitimate International Bank. The Bank offered a remarkable interest rate. They promised that given an initial investment of x, the balance…
1.欧几里得算法(辗转相除法) 直接上gcd和lcm代码. int gcd(int x,int y){ ?x:gcd(y,x%y); } int lcm(int x,int y){ return x*y/gcd(x,y); } 2.扩欧:exgcd:对于a,b,一定存在整数对(x,y)使ax+by=gcd(a,b)=d ,且a,b互质时,d=1. x,y可递归地求得. 我懒得改返回值类型了 long long exgcd(long long a,long long b,long long &x,…
扩展中国剩余定理板子 #include<iostream> #include<cstdio> using namespace std; const int N=100005; int n; long long m[N],r[N],M,R,x,y,d; void exgcd(long long a,long long b,long long &d,long long &x,long long &y) { if(!b) { d=a,x=1,y=0; return…
扩展中国剩余定理的板子,合并完之后算一下范围内能取几个值即可(记得去掉0) #include<iostream> #include<cstdio> #include<cmath> using namespace std; const int N=15; int T,n,m; long long a[N],b[N],A,B,x,y,d; bool fl; void exgcd(long long a,long long b,long long &d,long lo…