fork download
  1. #include <iostream>
  2. using namespace std;
  3. #define int long long
  4. int ltnp(int a, int b)
  5. {
  6. int kq=1,d,c;
  7. while (b>0)
  8. {
  9. c=1; d=a;
  10. while (c<=b/2) { c=c*2; d=(d*d)%10000; }
  11. b-=c; kq=(kq*d)%10000;
  12. }
  13. return kq;
  14. }
  15. signed main()
  16. {
  17. int a,b; cin>>a>>b; cout<<ltnp(a,b);
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5280KB
stdin
2 10
stdout
1024