Task: | Exponentiation |
Sender: | minghao |
Submission time: | 2024-11-14 15:51:45 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.61 s | details |
#3 | ACCEPTED | 0.62 s | details |
Compiler report
input/code.cpp: In function 'void Test()': input/code.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 45 | freopen("temp\\in.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code
#include <bits/stdc++.h> typedef long long LL; using namespace std; LL M = 1e9 + 7; inline LL Add(const LL& a, const LL& b) { LL c = a + b; if(c > M) c -= M; if(c < 0) c += M; return c; } inline LL Mul(const LL& a, const LL& b) { return (a * b) % M; } LL MulSlow(LL a, LL b) { LL ans = 0; while(b) { if(b & 1) ans = Add(ans, a); a = Add(a, a); b >>= 1; } return ans; } LL Pow(LL a, int k) { LL ans = 1; while(k) { if(k & 1) ans = Mul(ans, a); a = Mul(a, a); k >>= 1; } return ans; } void Test() { freopen("temp\\in.txt", "r", stdin); } int main() { // Test(); int n; cin >> n; while (n--) { LL a, b; cin >> a >> b; cout << Pow(a, b) << endl; } return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10201 0 0 0 1 0 2 0 3 ... |
correct output |
---|
1 0 0 0 0 ... |
user output |
---|
1 0 0 0 0 ... Truncated |
Test 2
Verdict: ACCEPTED
input |
---|
200000 129612095 411099530 241615980 487174929 60862511 511830781 758816482 982657640 ... |
correct output |
---|
276067146 838400234 148093882 546897305 467086232 ... |
user output |
---|
276067146 838400234 148093882 546897305 467086232 ... Truncated |
Test 3
Verdict: ACCEPTED
input |
---|
200000 692427692 536870911 252480658 536870911 505090334 536870911 27194853 536870911 ... |
correct output |
---|
940305728 707431813 917260341 908974199 375947818 ... |
user output |
---|
940305728 707431813 917260341 908974199 375947818 ... Truncated |