# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19410 | ilbbke | Σ (kriii4_P2) | C++98 | 12 ms | 1084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |