版本比较
题解 P4777 【【模板】扩展中国剩余定理(EXCRT)】
正文
增加 9 行删除 9 行
38 行未改动394041424343444546474849505152525354555668 行未改动12512612712812912913013113213324 行未改动1581591601611621621631641651641651661671671681691701718 行未改动18018118218318418418518618618718818938 行未改动#include<string>#include<algorithm>#include<math.h>#include<time.h>#include<map> #include<map>using namespace std;
map<long long,bool> M;const long long mod=1234577;int n,tl,ftl;long long a[100005],b[100005],fac[20];struct node{ long long A,B,C;//mod A^B=C long long A,B,C;//mod A^B=C};node t[1500005];bool cmp(node x,node y){68 行未改动 } exgcd(b,a%b,x,y); long long tmp=x; x=y; y=tmp-a/b*y; y=tmp-a/b*y;}
long long CRT(){24 行未改动 for(i=1;i<=n;++i) { scanf("%lld%lld",&a[i],&b[i]); if(a[i]==1) continue; add(a[i],b[i]); add(a[i],b[i]); } // cout<<clock()<<endl;
// cout<<clock()<<endl; sort(t+1,t+tl+1,cmp);
l=r=1; while(l<=tl) { maxx=t[l].B,mm=t[l].C;8 行未改动 } a[++ftl]=pow(t[l].A,maxx),b[ftl]=mm; l=r+1,r=l; }
printf("%lld\n",CRT());
return 0;}```