fork download
  1. #include <bits/stdc++.h>
  2. #define e 1000000007
  3. using namespace std;
  4. int a;
  5. long long b;
  6. int lt(int a, long long b)
  7. {
  8. if(b==0) return 1;
  9. int t=lt(a,b/2);
  10. t=((long long)t*t)%e;
  11. if(b%2) t=((long long)t*a)%e;
  12. return t;
  13. }
  14. int main()
  15. {
  16. while(1)
  17. {
  18. cin>>a>>b;
  19. if(a==0&&b==0) break;
  20. int kq=lt(a,b);
  21. cout<<kq<<"\n";
  22. }
  23. }
Success #stdin #stdout 0s 3416KB
stdin
2 3
2 4
3 2
0 0
stdout
8
16
9