2 solutions

  • 1
    @ 2025-8-7 9:11:12
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long n;
        cin>>n;
        for(int a=1;a<=15;a++)
        {
            if(pow(a,a)==n)
            {
                cout<<a;
                return 0;
            }
        }
        cout<<-1;
        return 0;
    }
    
    • 1
      @ 2025-5-12 17:16:02
      #include<bits/stdc++.h>
      using namespace std;
      typedef long long LL; 
      int main()
      {
      	LL n;
      	cin>>n;
      	int ans=-1;
      	for(int i=1;i<=100;i++)
      	{
      		LL t=1;
      		for(int j=1;j<=i;j++)
      		{
      			t=t*i;
      		}
      		if(t==n)
      		{
      			ans=i;
      			break;
      		}
      	}
      	cout<<ans;
      	return 0;
      }
      
      
      • 1

      Information

      ID
      2339
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      75
      Accepted
      27
      Uploaded By