fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define fi first
  5. #define se second
  6. #define N 100005
  7. #define mds ll(1e9+7)
  8. typedef long long ll;
  9.  
  10. ll fastpow(ll a,ll n,ll md)
  11. {
  12. ll res=1;
  13. while (n>0)
  14. {
  15. if (n&1) res=(res*a)%md;
  16. n/=2;
  17. a=a*a%md;
  18. }
  19. return res;
  20. }
  21.  
  22. int main()
  23. {
  24. ios_base::sync_with_stdio(NULL);
  25. cin.tie(NULL);
  26.  
  27. #ifndef ONLINE_JUDGE
  28. freopen("input.inp","r",stdin);
  29. freopen("output.out","w",stdout);
  30. #endif
  31.  
  32. ll x;string s;cin>>x>>s;
  33. ll res=1;
  34. for (int i=0;i<s.size();i++)
  35. res=res*fastpow(fastpow(x,s[i]-'0',mds),fastpow(10,s.size()-i-1,mds-1),mds)%mds;
  36.  
  37. cout<<res;
  38.  
  39.  
  40. }
  41.  
Success #stdin #stdout 0.01s 5520KB
stdin
Standard input is empty
stdout
1