Submission

Status:
[-SSSSSSSSSSSSSSSSSSS]

Score: 0

User: K3

Problemset: ยกกำลัง

Language: cpp

Time: 0.021 second

Submitted On: 2024-11-20 20:25:40

#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;
    base %= mod;
    while (exp > 0) {
        if (exp % 2 == 1) {
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        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);
    }
}