SHARE
TWEET

Untitled

a guest Sep 15th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. // #define f first
  5. // #define s second
  6. const int N = 200000000;
  7. const int mod = 10000007;
  8. #define int long long
  9. int f(int a,int b)
  10. {
  11.     int res = 1;
  12.     //if(mp[b])return mp[b];
  13.     while(b)
  14.     {
  15.         if(b & 1)
  16.         {
  17.             res = ( res* a)%mod;
  18.         }
  19.         b = b >> 1;
  20.         a  = ( a  * a )%mod;
  21.     }
  22.     //return mp[b]=res;
  23.     return res;
  24. }
  25. void solve(int a,int b)
  26. {
  27.    
  28.     int A = f(a,b) +(2 * f(a-1 , b)) % mod;
  29.     int B = f(a, a) +(2* f(a-1 , a-1))%mod;
  30.     cout<<(A + B)%mod<<"\n";
  31.    
  32.        
  33. }
  34. int32_t main()
  35. {  
  36.    
  37.   while(true)
  38.   {
  39.       int a,b;
  40.       cin >> a >> b;
  41.       if(!a && !b)return 0;
  42.       solve(a , b);
  43.   }
  44. return 0;
  45.  
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top