Submission #19634

# Submission time Handle Problem Language Result Execution time Memory
19634 2016-02-25T02:57:23 Z yongwhan Σ (kriii4_P2) C++
0 / 100
14 ms 1720 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mod=1e9+7;

ll exp(ll a, ll b, ll m) {
  ll r=1;
  while(b) {
    if(b%2) r=(r*a)%m;
    a=(a*a)%m;
    b/=2;
  }
  return r;
}

ll inv(ll a, ll m) {
  return exp(a,m-2,m);
}

int main() {
  int m; cin>>m;
  ll ret=0;
  for (int i=0; i<m; i++) {
    ll n,s; cin>>n>>s;
    ret+=(ret+s*inv(n,mod))%mod;
  }
  cout << ret << endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1720 KB Output isn't correct
2 Halted 0 ms 0 KB -