标签:expr through lov color nbsp target get text TE
分明$excrt$就过了。
为什么还要仔细读题呢?
$qwq$
反正我没读题然后被卡$long \ long +$输出格式错$……$总共$WA$了四次
怕不是要退役……
上代码:
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; long long a[100010],r[100010]; int n; long long exgcd(long long a,long long b,long long &x,long long &y) { if(b==0) return x=1,y=0,a; long long tmp=exgcd(b,a%b,y,x); y-=a/b*x; return tmp; } long long slove() { long long M=a[1],R=r[1],x,y,d; for(int i=2;i<=n;i++) { d=exgcd(M,a[i],x,y); if((R-r[i])%d!=0) return -1; x=(R-r[i])/d*x%a[i]; R-=x*M; M=M/d*a[i]; R%=M; } return (R%M+M)%M; } int main() { while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&r[i]); printf("%lld\n",slove()); } return 0; }
poj2891:Strange Way to Express Integers
标签:expr through lov color nbsp target get text TE
原文地址:https://www.cnblogs.com/cn-suqingnian/p/9252147.html