#include<cstdio> #include<string> #include<cstring> #define WR WinterRain using namespace std; const long long WR=1001000; struct pig{ long long a,b; }p[WR]; long long n,ans,sum=1; long long read(){ long long s=0,w=1; char ch=getchar(); while(ch>'9'||ch<'0'){ if(ch=='-') w=-1; ch=getchar(); } while(ch<='9'&&ch>='0'){ s=(s<<3)+(s<<1)+ch-'0'; ch=getchar(); } return s*w; } long long gcd(long long x,long long y){ if(!y) return x; return gcd(y,x%y); } int main(){ n=read(); for(long long i=1;i<=n;i++){ p[i].a=read(),p[i].b=read(); } ans=p[1].b; for(long long i=1;i<n;i++){ sum=sum*p[i].a/gcd(sum,p[i].a); while(ans%p[i+1].a!=p[i+1].b){ ans+=sum; } } printf("%lld",ans); return 0; }
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/276421.html