Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define endl '\n'
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
- ll n, m;
- cin >> n >> m;
- ll a = 2, x = 1;
- while(m>0) {
- if(m&1) {
- x*=a;
- if(x>=1000000007) x%=1000000007;
- }
- a*=a;
- if(a>=1000000007) a%=1000000007;
- m>>=1;
- }
- x--;
- ll ans = 1;
- while(n>0) {
- if(n&1) {
- ans*=x;
- if(ans>=1000000007) ans%=1000000007;
- }
- x*=x;
- if(x>=1000000007) x%=1000000007;
- n>>=1;
- }
- cout << ans;
- return 0;
- }
- /*
- 6:6+15+20+15+6+1=63 (31+16*2)
- 5:5+10+10+5+1=31 (15+8*2)
- 4:4+6+4+1=15 (7+4*2)
- 3:3+3+1=7 (3+2*2)
- 2:2+1=3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement