Submission #19351

# Submission time Handle Problem Language Result Execution time Memory
19351 2016-02-24T10:25:38 Z ilbbke Σ (kriii4_P2) C++
0 / 100
0 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("%d",ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1084 KB Output isn't correct
2 Halted 0 ms 0 KB -