Submission #19332

#TimeUsernameProblemLanguageResultExecution timeMemory
19332exqtΣ (kriii4_P2)C++98
100 / 100
28 ms2000 KiB
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <queue> #include <string> #include <cstring> #include <map> using namespace std; #define in cin #define out cout #define ll long long int ll DV = 1000000007; ll mypow(ll a, ll b) { ll t = a; ll res = 1; while(b) { if(b%2) res = (res * t) % DV; t = t % DV; t = (t*t) % DV; b = b >> 1; } return res; } ll myinv(ll a) { return mypow(a, DV-2); } int main() { int n; in >> n; ll mb = 1; vector<ll> va, vb; for(int i=0; i<n; i++) { ll a, b; in >> b >> a; va.push_back(a); vb.push_back(b); mb *= b; mb %= DV; } ll u = 0; for(int i=0; i<n; i++) { u += ((va[i]%DV)*(mb%DV)%DV)*(myinv(vb[i])%DV); u %= DV; } out << (u)*(myinv(mb))%DV; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...