-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBITTUP.cpp
More file actions
42 lines (35 loc) · 694 Bytes
/
BITTUP.cpp
File metadata and controls
42 lines (35 loc) · 694 Bytes
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
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll x, ll y){
ll res = 1;
while(y){
if(y%2 == 1)
res = (res*x);
y = y >> 1;
x = (x*x);
}
return res;
}
ll Power(ll x, unsigned int y, ll p){
ll res = 1;
x = x%p;
if(x == 0) return 0;
while(y > 0){
if(y & 1)
res = (res*x) % p;
y = y >> 1;
x = (x*x) % p;
}
return res;
}
int main(){
ll t; cin >> t;
while(t--){
ll mod = power(10,9)+7;
ll n, m; cin >> n >> m;
ll ans = Power(2,n,mod) - 1;
ll mainAns = Power(ans, m, mod);
cout << mainAns << endl;
}
}