Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define pb push_back
- // #define f first
- // #define s second
- const int N = 200000000;
- const int mod = 10000007;
- #define int long long
- int f(int a,int b)
- {
- int res = 1;
- //if(mp[b])return mp[b];
- while(b)
- {
- if(b & 1)
- {
- res = ( res* a)%mod;
- }
- b = b >> 1;
- a = ( a * a )%mod;
- }
- //return mp[b]=res;
- return res;
- }
- void solve(int a,int b)
- {
- int A = f(a,b) +(2 * f(a-1 , b)) % mod;
- int B = f(a, a) +(2* f(a-1 , a-1))%mod;
- cout<<(A + B)%mod<<"\n";
- }
- int32_t main()
- {
- while(true)
- {
- int a,b;
- cin >> a >> b;
- if(!a && !b)return 0;
- solve(a , b);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement