CSES - Aalto Competitive Programming 2024 - wk11 - Homework - Results
Submission details
Task:Exponentiation
Sender:hungdojan
Submission time:2024-11-16 02:04:06 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.10 sdetails
#3ACCEPTED0.10 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
#define I_2D(row, col, width) ((row) * (width) + (col))
#define PRINT_ARR(arr, n) \
do { \
for (int i = 0; i < n; i++) { \
cout << arr[i] << " "; \
} \
cout << "\n"; \
} while (0)
#define PRINT_VEC_ARR(v, n) \
do { \
for (int i = 0; i < n; i++) { \
cout << i << ": "; \
for (auto item : v[i]) { \
cout << item << " "; \
} \
cout << endl; \
} \
} while (0)
#define endl '\n';
typedef long long ll;
// #define MOD (int)1e9 + 7
// #define MOD
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
ll a, b, res;
for (int i = 0; i < n; i++) {
cin >> a >> b;
res = (b & 1) ? a : 1;
b >>= 1;
while (b) {
a = (a * a) % 1000000007L;
if (b & 1) {
res *= a;
res %= 1000000007L;
}
b >>= 1;
}
cout << res << 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