Submission
Status:
[PPPPPPPPPPPPPPPPPPPP]
Score: 100
User: Nathlol2
Problemset: ยกกำลัง
Language: cpp
Time: 0.024 second
Submitted On: 2024-10-24 13:36:38
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1000000007;
void solve(){
ll a, b;
cin >> a >> b;
long long result = 1;
a = a % mod;
while (b > 0) {
if (b % 2 == 1) {
result = (result * a) % mod;
}
b = b >> 1;
a = (a * a) % mod;
}
cout << result << endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
}