Submission details
Task:Exponentiation
Sender:ind1f
Submission time:2025-11-17 17:09:05 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.12 sdetails
#3ACCEPTED0.11 sdetails

Code

#include <iostream>

using namespace std;

const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}

int mul(int a, int b) {
  return 1LL * a * b % MOD;
}

int mod_pow(int a, int b) {
  int r = 1;
  for (; b > 0; a = mul(a, a), b >>= 1) {
    if (b & 1) {
      r = mul(r, a);
    }
  }
  return r;
}

int n, a, b;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  while (n--) {
    cin >> a >> b;
    cout << mod_pow(a, b) << '\n';
  }
  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