-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.py
More file actions
executable file
·56 lines (38 loc) · 919 Bytes
/
Copy pathsol.py
File metadata and controls
executable file
·56 lines (38 loc) · 919 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# f = [0] * (10 ** 6 + 1)
cache = []
def ncr(n, k):
global cache
k = min(k, n - k)
if len(cache) == k + 1:
return cache[k]
result = 1
for i in range(1, k + 1):
result *= (n + 1 - i) / (i)
cache.append(int(result))
# print(k, cache)
return cache[k]
# return f[n] // f[r] // f[n - r]
def solve():
global cache
cache = [0]
N, M = [int(x) for x in str(input()).split(" ")]
fn = 1
for i in range(1, N):
fn += ncr(N, i)
result = fn ** M
result %= 10 ** 9 + 7
print(result)
def solve2():
N, M = [int(x) for x in str(input()).split(" ")]
total_tuples = (2 ** M) ** N
if __name__ == "__main__":
# for i in range(0, 10 ** 6 + 1):
# if i <= 1:
# f[i] = i
# else:
# f[i] = f[i - 1] * i
T = int(input())
while T:
# solve()
solve2()
T -= 1