-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlixeira5.cpp
More file actions
53 lines (45 loc) · 1.09 KB
/
lixeira5.cpp
File metadata and controls
53 lines (45 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007ll
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<< #x << " = " << x << "\033[0m" << endl;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0);
long long binpow(long long x, long long n, long long m = 1) {
x %= m;
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * x % m;
x = x * x % m;
n >>= 1;
}
return res;
}
int main() {
FASTIO;
ll n, a, b;
cin >> n;
FOR(i, 0, n){
cin >> a >> b;
cout << binpow(a, b, MOD) << endl;
}
return 0;
}