Submission #19636

#TimeUsernameProblemLanguageResultExecution timeMemory
19636yongwhanΣ (kriii4_P2)C++98
100 / 100
17 ms1720 KiB
#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 timeMemoryGrader output
Fetching results...