Submission
Status:
[-SSSSSSSSSSSSSSSSSSS]
Score: 0
User: K3
Problemset: ยกกำลัง
Language: cpp
Time: 0.029 second
Submitted On: 2024-11-20 20:24:01
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long power(long long base, long long exp) {
long long result = 1;
while (exp > 0) {
if (exp % 2 == 1) {
result *= base;
}
base *= base;
exp /= 2;
}
return result;
}
int main() {
int num; cin >> num;
for (int i=0;i<num;i++) {
int x , y; cin >> x >> y;
cout << power(x,y) % mod;
}
}