# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19332 | exqt | Σ (kriii4_P2) | C++98 | 28 ms | 2000 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |