Submission #19410

#TimeUsernameProblemLanguageResultExecution timeMemory
19410ilbbkeΣ (kriii4_P2)C++98
100 / 100
12 ms1084 KiB
#include<stdio.h> #define M 1000000007 int m; long long ans,a,b; long long back(int x){ long long t; if(x==0) return 1; if(x==1) return b; if(x==2) return b*b; t=back(x/2); return x%2?t*t%M*b%M:t*t%M; } long long f(long long x,long long y){ long long c; while(y) { c=x%y; x=y; y=c; } return x; } int main() { scanf("%d",&m); int i; long long x; for(i=1;i<=m;i++){ scanf("%lld %lld",&b,&a); x=f(a,b); a=a/x; b=b/x; x=back(1000000005); ans=(ans+(x*a%M))%M; } printf("%lld",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...