fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int power(int n){
  7. int x;
  8. const int max_x = 101010101;
  9. if (n < 27) x = pow(2, n);
  10. else{
  11. x = pow(2, 27) - max_x;
  12. for (int i = 1; i <= n-27; i++){
  13. x *= 2;
  14. if (x > max_x)
  15. x -= max_x;
  16. }
  17. }
  18. return x;
  19. }
  20.  
  21. int main(){
  22. int t;
  23. cin >> t;
  24. while(t--){
  25. int n, result;
  26. const int max_result = 101010101;
  27. cin >> n;
  28. if (n%2 == 0) result = 2*power(n/2);
  29. else result = power(n/2) + power((n+1)/2);
  30. cout << result % max_result << '\n';
  31. }
  32. }
Success #stdin #stdout 0s 4496KB
stdin
2
2
3
stdout
4
6