1236B.md (2509B)
1 Source: https://codeforces.com/problemset/problem/1236/B 2 3 B. Alice and the List of Presents 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. 22 23 There are $n$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind. 24 25 Also, there are $m$ boxes. All of them are for different people, so they are pairwise distinct (consider that the names of $m$ friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box. 26 27 Alice wants to pack presents with the following rules: 28 29 * She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of $n$ kinds, empty boxes are allowed); 30 * For each kind at least one present should be packed into some box. 31 32 Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo $10^9+7$. 33 34 See examples and their notes for clarification. 35 36 Input 37 38 The first line contains two integers $n$ and $m$, separated by spaces ($1 \leq n,m \leq 10^9$) — the number of kinds of presents and the number of boxes that Alice has. 39 40 Output 41 42 Print one integer — the number of ways to pack the presents with Alice's rules, calculated by modulo $10^9+7$ 43 44 Examples 45 46 Input 47 48 ``` 49 1 3 50 ``` 51 52 Output 53 54 ``` 55 7 56 ``` 57 58 Input 59 60 ``` 61 2 2 62 ``` 63 64 Output 65 66 ``` 67 9 68 ``` 69 70 Note 71 72 In the first example, there are seven ways to pack presents: 73 74 $\{1\}\{\}\{\}$ 75 76 $\{\}\{1\}\{\}$ 77 78 $\{\}\{\}\{1\}$ 79 80 $\{1\}\{1\}\{\}$ 81 82 $\{\}\{1\}\{1\}$ 83 84 $\{1\}\{\}\{1\}$ 85 86 $\{1\}\{1\}\{1\}$ 87 88 In the second example there are nine ways to pack presents: 89 90 $\{\}\{1,2\}$ 91 92 $\{1\}\{2\}$ 93 94 $\{1\}\{1,2\}$ 95 96 $\{2\}\{1\}$ 97 98 $\{2\}\{1,2\}$ 99 100 $\{1,2\}\{\}$ 101 102 $\{1,2\}\{1\}$ 103 104 $\{1,2\}\{2\}$ 105 106 $\{1,2\}\{1,2\}$ 107 108 For example, the way $\{2\}\{2\}$ is wrong, because presents of the first kind should be used in the least one box.