Submission #47225250


Source Code Expand

#include <iostream>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <set>
#include <vector>
#include<algorithm>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
const int mod = 1e9 + 7;
const int N = 200005;
const double pai=acos(-1.0);
ll tt;
int a[N];
long long qpow(long long base,long long power){
        long long ans=1;
        while(power>0){
            if(power%2==1) ans=ans*base;
            power/=2;
            base=base*base;
        }
        return ans;
    }
void solve() {
    ll b,ans=1;
    cin>>b;
    for(ll i=1;;i++){
        ans=qpow(i,i);
        if(ans==b){
        	cout<<i;
        	return ;
		}
		else if(ans>b){
			cout<<-1;
			return ;
		}
	}
    return ;
}
signed main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}

Submission Info

Submission Time
Task B - A^A
User Kary
Language C++ 20 (gcc 12.2)
Score 200
Code Size 992 Byte
Status AC
Exec Time 1 ms
Memory 3592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 21
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_hack_1_00.txt, 02_hack_1_01.txt, 03_hack_2_00.txt, 03_hack_2_01.txt, 03_hack_2_02.txt, 03_hack_2_03.txt, 04_corner_00.txt, 04_corner_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3468 KiB
00_sample_01.txt AC 1 ms 3456 KiB
00_sample_02.txt AC 1 ms 3456 KiB
01_random_00.txt AC 1 ms 3392 KiB
01_random_01.txt AC 1 ms 3528 KiB
01_random_02.txt AC 1 ms 3532 KiB
01_random_03.txt AC 1 ms 3460 KiB
01_random_04.txt AC 1 ms 3592 KiB
01_random_05.txt AC 1 ms 3452 KiB
01_random_06.txt AC 1 ms 3460 KiB
01_random_07.txt AC 1 ms 3524 KiB
01_random_08.txt AC 1 ms 3444 KiB
01_random_09.txt AC 1 ms 3324 KiB
02_hack_1_00.txt AC 1 ms 3412 KiB
02_hack_1_01.txt AC 1 ms 3408 KiB
03_hack_2_00.txt AC 1 ms 3476 KiB
03_hack_2_01.txt AC 1 ms 3468 KiB
03_hack_2_02.txt AC 1 ms 3460 KiB
03_hack_2_03.txt AC 1 ms 3444 KiB
04_corner_00.txt AC 1 ms 3444 KiB
04_corner_01.txt AC 1 ms 3404 KiB