fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define MAX 100000
  5. #define input(); freopen("input.txt", "r", stdin);
  6. #define output(); freopen("output.txt", "w", stdout);
  7. #define IOS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
  8.  
  9. typedef long long ll;
  10.  
  11. ll squers[MAX];
  12. void Find_squers(){
  13. for(int i=0; i<MAX; ++i){
  14. squers[i] = 1LL * i * i;
  15. }
  16. return;
  17. }
  18. int main()
  19. {
  20.  
  21. IOS;
  22. Find_squers();
  23. int T, csno = 0;
  24. ll limit, a, b,p;
  25. cin >> T;
  26. while(T--){
  27. cin >> p;
  28. cout << "Case " << ++csno << ": ";
  29. limit = sqrt(p);
  30. bool End = false;
  31. for(ll i=0; i<MAX; ++i){
  32. if(squers[i] + squers[limit] == p){
  33. cout << i << " " << limit << endl;
  34. End = true; break;
  35. }
  36. else if(squers[i] + squers[limit] > p)
  37. --limit;
  38. else if(i>limit)
  39. break;
  40. }
  41. if(!End)
  42. cout << "Impossible\n";
  43. }
  44. return 0;
  45. }
  46.  
  47.  
  48.  
Runtime error #stdin #stdout 0s 16016KB
stdin
Standard input is empty
stdout
Standard output is empty