-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13172.cpp
More file actions
51 lines (51 loc) · 1.05 KB
/
13172.cpp
File metadata and controls
51 lines (51 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define ft first
#define sd second
#define all(x) (x).begin(), (x).end()
#define MOD 1'000'000'007
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vd = vector<double>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vvpii = vector<vpii>;
using vvpll = vector<vpll>;
using vvs = vector<vs>;
ll get(ll num,ll pow){
if(pow==1){
return num;
}
ll half = get(num,pow/2);
half = (half*half)%MOD;
if(pow&1){
half=(half*num)%MOD;
}
return half;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int m;
cin>>m;
ll ans=0,b,a;
while(m--){
cin>>b>>a;
//a * b^1000000005
ll GCD = __gcd(a,b);
a/=GCD;
b/=GCD;
ans+=(a*(get(b,MOD-2)));
ans%=MOD;
}
cout<<ans;
}