# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19353 |
2016-02-24T10:26:19 Z |
algoshipda |
Σ (kriii4_P2) |
C++14 |
|
19 ms |
1720 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
const int MOD = 1e9 + 7;
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int fpow(int n, int k)
{
if(k == 0) return 1;
if(k % 2){
return 1ll * n * fpow(n, k - 1) % MOD;
}
int h = fpow(n, k / 2);
return 1ll * h * h % MOD;
}
int main()
{
int t;
cin >> t;
int s = 0;
while(t--){
int n, k;
cin >> k >> n;
int g = gcd(k, n);
k /= g;
n /= g;
s += 1ll * n * fpow(k, MOD - 2) % MOD;
s %= MOD;
}
cout << s << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
1720 KB |
Output is correct |
2 |
Correct |
17 ms |
1720 KB |
Output is correct |
3 |
Correct |
18 ms |
1720 KB |
Output is correct |
4 |
Correct |
9 ms |
1720 KB |
Output is correct |
5 |
Correct |
17 ms |
1720 KB |
Output is correct |
6 |
Correct |
15 ms |
1720 KB |
Output is correct |
7 |
Correct |
17 ms |
1720 KB |
Output is correct |
8 |
Correct |
15 ms |
1720 KB |
Output is correct |
9 |
Correct |
18 ms |
1720 KB |
Output is correct |
10 |
Correct |
19 ms |
1720 KB |
Output is correct |
11 |
Correct |
18 ms |
1720 KB |
Output is correct |
12 |
Correct |
18 ms |
1720 KB |
Output is correct |
13 |
Correct |
19 ms |
1720 KB |
Output is correct |
14 |
Correct |
15 ms |
1720 KB |
Output is correct |
15 |
Correct |
19 ms |
1720 KB |
Output is correct |
16 |
Correct |
16 ms |
1720 KB |
Output is correct |
17 |
Correct |
17 ms |
1720 KB |
Output is correct |
18 |
Correct |
17 ms |
1720 KB |
Output is correct |
19 |
Correct |
12 ms |
1720 KB |
Output is correct |
20 |
Correct |
17 ms |
1720 KB |
Output is correct |