# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19328 | xdoju | Σ (kriii4_P2) | C++14 | 6 ms | 1084 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 <cstdio>
using namespace std;
const long long MOD = 1000000007ll;
long modpow(long long r, long long n) {
long long ret = 1;
while (n > 0) {
if (n % 2 > 0) {
ret = (ret * r) % MOD;
}
r = (r * r) % MOD;
n /= 2;
}
return ret;
}
long long modinv(int n) {
return modpow(n, MOD - 2);
}
void proc() {
int m;
scanf("%d", &m);
long long res = 0;
for (int i = 0; i < m; ++i) {
int face, sum;
long long u = 1;
scanf("%d %d", &face, &sum);
u = (u * sum) % MOD;
u = (u * modinv(face)) % MOD;
res = (res + u) % MOD;
}
printf("%lld", res);
}
int main() {
proc();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |