fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. string s;
  10. cin >> s;
  11. int a=0;
  12. int cnt =1;
  13. for(int i=3;i>=0;i--){
  14. a+=(s[i]-'0')*cnt;
  15. cnt*=10;
  16. }
  17. int k =(int)sqrt(a);
  18. if(k*k==a){
  19. cout << "0 " << k << '\n';
  20. }
  21. else
  22. cout << -1 << '\n';
  23. }
  24.  
  25. int main(){
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28.  
  29. int t;
  30. cin >> t;
  31. while (t--) solve();
  32.  
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 5332KB
stdin
5
0001
1001
1000
4900
2025
stdout
0 1
-1
-1
0 70
0 45