2 solutions

  • 1
    @ 2026-2-4 13:22:59
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long t;
        cin>>t;
        for(long long i=0;i<t;i++)
        {
            long long a;
            cin>>a;
            for(long long b=1;b<=a;b++)
            {
                if(b*b*b*b==a)
                {
                    cout<<b;
                    cout<<"\n";
                    b=0;
                    break;
                }
                else if(b==a)
                {
                    cout<<"-1\n";
                }
            }
        }
    }
    
    • -1
      @ 2025-11-27 11:55:04

      C++ :

      #include <iostream>
      #include <cmath>
      using namespace std;
      int main() {
          int t;
          cin >> t;
          while (t--) {
              int a;
              cin >> a;
              int b = (int)(sqrt(sqrt(a)));
              if (b * b * b * b == a) {
                  cout << b << endl;
              } else {
                  cout << -1 << endl;
              }
          }
          return 0;
      }
      
      • 1

      Information

      ID
      30
      Time
      5000ms
      Memory
      128MiB
      Difficulty
      6
      Tags
      # Submissions
      19
      Accepted
      10
      Uploaded By