답안 #19636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19636 2016-02-25T02:59:08 Z yongwhan Σ (kriii4_P2) C++
100 / 100
17 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1720 KB Output is correct
2 Correct 15 ms 1720 KB Output is correct
3 Correct 13 ms 1720 KB Output is correct
4 Correct 14 ms 1720 KB Output is correct
5 Correct 14 ms 1720 KB Output is correct
6 Correct 14 ms 1720 KB Output is correct
7 Correct 13 ms 1720 KB Output is correct
8 Correct 12 ms 1720 KB Output is correct
9 Correct 15 ms 1720 KB Output is correct
10 Correct 11 ms 1720 KB Output is correct
11 Correct 11 ms 1720 KB Output is correct
12 Correct 15 ms 1720 KB Output is correct
13 Correct 12 ms 1720 KB Output is correct
14 Correct 12 ms 1720 KB Output is correct
15 Correct 11 ms 1720 KB Output is correct
16 Correct 14 ms 1720 KB Output is correct
17 Correct 9 ms 1720 KB Output is correct
18 Correct 13 ms 1720 KB Output is correct
19 Correct 14 ms 1720 KB Output is correct
20 Correct 15 ms 1720 KB Output is correct