Submission #19412

#TimeUsernameProblemLanguageResultExecution timeMemory
19412ekfrl0526Σ (kriii4_P2)C++14
100 / 100
11 ms1720 KiB
#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 timeMemoryGrader output
Fetching results...