Submission #19404

# Submission time Handle Problem Language Result Execution time Memory
19404 2016-02-24T11:22:47 Z ilbbke Σ (kriii4_P2) C++
0 / 100
4 ms 1084 KB
#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(c!=0)
    {
        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
1 Incorrect 4 ms 1084 KB Output isn't correct
2 Halted 0 ms 0 KB -