# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19412 | ekfrl0526 | Σ (kriii4_P2) | C++14 | 11 ms | 1720 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<bits/stdc++.h>
using namespace std;
const long long divs = 1000000007;
vector<long long> as;
void initial(long long a) {
long long ia = a;;
for (int i = 0; i < 64; i++) {
if (ia >= divs) ia = ia%divs;
as.push_back(ia);
ia *= ia;
}
}
int main() {
int n;
long long ans = 0;
scanf("%d ", &n);
while (n--) {
as.clear();
long long a, b;
long long x = divs - 2;
scanf("%lld %lld", &b, &a);
initial(b);
int c = 0;
long long result = 1;
while (x > 0) {
if (x % 2 == 1) {
result *= as[c];
result %= divs;
}
x /= 2;
c++;
}
result *= a % divs;
result %= divs;
ans += result;
ans %= divs;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |