Submission

Status:
[PPPPPPPPPPPPPPPPPPPP]

Score: 100

User: lazybw_

Problemset: ยกกำลัง

Language: cpp

Time: 0.006 second

Submitted On: 2025-01-18 22:28:14

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

long long solve(long long n, long long m) {
    long long res = 1;
    n %= MOD;
    while (m > 0) {
        if (m & 1)
            res = (res * n) % MOD;
        n = (n * n) % MOD;
        m >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr);
    int q; cin>>q; while(q--) {
        long long n, m; cin>>n>>m;
        cout<<solve(n, m)<<'\n';
    }

    return 0;
}