fork(1) download
  1. #include<iostream>
  2. #include <stdio.h>
  3. #include<string>
  4. #include <math.h>
  5. #include <stdlib.h>
  6. unsigned long long int call(unsigned long long int a,unsigned long long int b)
  7. {
  8. unsigned long long int res;
  9. if(b==0)
  10. return 1;
  11. if(b==1)
  12. return a;
  13. res=call(a,b/2);
  14. res=(res*res)%1000000007;
  15. if(b%2)
  16. res=(res*a)%1000000007;
  17. return res;
  18. }
  19. int main() {
  20. unsigned long long int a,b,r;
  21. int t,i=0;
  22. std::string A,B;
  23. scanf("%d",&t);
  24. getchar();
  25. while(t--)
  26. {
  27. std::cin>>A>>B;
  28. i=0;
  29. a=0;
  30. b=0;
  31. while(A[i])
  32. {
  33. a=(a*10+(A[i]-'0'))%1000000007;
  34. i++;
  35. }
  36. i=0;
  37. while(B[i])
  38. {
  39. b=(b*10+(B[i]-'0'))%1000000007;
  40. i++;
  41. }
  42. r=call(a,b);
  43. printf("%llu\n",r);
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 2820KB
stdin
2
2 8
3 15
stdout
256
14348907