#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
const ll MOD = 1e9 + 7;
ll pw(ll a,ll b){
a %= MOD;
ll res = 1;
while(b){
if(b&1)res = (res * a) % MOD;
a = (a * a) % MOD;
b >>= 1;
}
return res;
}
int main(){
int m;
scanf("%d", &m);
ll a = 0;
while(m--){
int x, y;
scanf("%d%d", &x, &y);
a = (a + y * pw(x, MOD-2)) % MOD;
}
printf("%lld", a);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
5 ms |
1720 KB |
Output is correct |
6 |
Correct |
4 ms |
1720 KB |
Output is correct |
7 |
Correct |
2 ms |
1720 KB |
Output is correct |
8 |
Correct |
0 ms |
1720 KB |
Output is correct |
9 |
Correct |
4 ms |
1720 KB |
Output is correct |
10 |
Correct |
6 ms |
1720 KB |
Output is correct |
11 |
Correct |
4 ms |
1720 KB |
Output is correct |
12 |
Correct |
6 ms |
1720 KB |
Output is correct |
13 |
Correct |
0 ms |
1720 KB |
Output is correct |
14 |
Correct |
0 ms |
1720 KB |
Output is correct |
15 |
Correct |
0 ms |
1720 KB |
Output is correct |
16 |
Correct |
0 ms |
1720 KB |
Output is correct |
17 |
Correct |
0 ms |
1720 KB |
Output is correct |
18 |
Correct |
0 ms |
1720 KB |
Output is correct |
19 |
Correct |
4 ms |
1720 KB |
Output is correct |
20 |
Correct |
0 ms |
1720 KB |
Output is correct |