fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. // Function to print a __int128_t value
  6. void print128(__int128_t x) {
  7. if (x == 0) {
  8. cout << 0;
  9. return;
  10. }
  11.  
  12. if (x < 0) {
  13. cout << '-';
  14. x = -x;
  15. }
  16.  
  17. // Recursively print digits
  18. string res;
  19. while (x > 0) {
  20. res.push_back('0' + (x % 10));
  21. x /= 10;
  22. }
  23. reverse(res.begin(), res.end());
  24. cout << res;
  25. }
  26.  
  27. int main() {
  28. ios::sync_with_stdio(0);
  29. cin.tie(0);
  30. int t = 1;
  31. cin >> t;
  32. while (t--) {
  33. ll n;
  34. cin >> n;
  35. __int128_t x = (__int128_t)n * (__int128_t)n;
  36.  
  37. // Custom print function for __int128_t
  38. print128(x);
  39. cout << "\n";
  40. }
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5288KB
stdin
2
1000000000000000000
3
stdout
1000000000000000000000000000000000000
9