fork download
  1. #include <bits/stdc++.h>
  2. #define li long long int
  3. #define MOD 1000000009
  4. using namespace std;
  5. li expo(li base, li expo)
  6. {
  7. li res = 1;
  8. while (expo)
  9. {
  10. if(expo%2 == 1) res = (res*base)%MOD;
  11. base = (base*base)%MOD;
  12. expo /=2;
  13. }
  14. return res;
  15. }
  16. int main()
  17. {
  18. li t,s,x,res,K;
  19. cin >> t;
  20. while ( t-- )
  21. {
  22. cin >> x >> s;
  23. K = s/(x*x);
  24. res = expo(K,x*x);
  25. cout << res << endl;
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 16064KB
stdin
2
2 4
2 16
stdout
1
256