fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ull unsigned long long int
  4. ull modulo(ull a,ull b,ull c)
  5. {
  6. ull x=1;
  7. while(b!=0)
  8. {
  9. if(b&1)
  10. x=modulo(x,a,c);
  11. a=modulo(a,a,c);
  12. b>>=1;
  13. }
  14. return x;
  15. }
  16. int main() {
  17. // your code goes here
  18. int t;
  19. scanf("%d",&t);
  20. while(t--)
  21. {
  22. ull a,b;
  23. scanf("%llu %llu",&a,&b);
  24. cout<<modulo(a,b,10)<<endl;
  25. }
  26. return 0;
  27. }
Runtime error #stdin #stdout 0s 11200KB
stdin
2
3 6
6 3
stdout
Standard output is empty