# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19244 | kaTkaHr | Σ (kriii4_P2) | C++14 | 742 ms | 1160 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 <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
const int MX = 10005, MM = 1000000007;
ll pw(ll A, ll B){
ll R = 1;
while(B){
if( B & 1 ) R = R * A % MM;
A = A * A % MM; B /= 2;
}
return R;
}
ll rv(ll A){ return pw(A, MM-2); }
int N[MX], S[MX];
int main()
{
int M;
scanf("%d", &M);
for(int i = 1; i <= M; i++){
scanf("%d%d", N+i, S+i);
}
ll ans = 0;
for(int i = 1; i <= M; i++){
ll t = 1;
for(int j = 1; j <= M; j++){
if(i == j) t = t * S[j] % MM;
else t = t * N[j] % MM;
}
ans = (ans + t) % MM;
}
for(int i = 1; i <= M; i++){
ans = ans * rv(N[i]) % MM;
}
printf("%lld\n", ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |