結果

問題 No.3236 累乗数大好きbot
ユーザー t98slider
提出日時 2025-08-15 22:20:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 97 ms / 4,000 ms
コード長 677 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 197,764 KB
実行使用メモリ 13,596 KB
最終ジャッジ日時 2025-08-15 22:20:55
合計ジャッジ時間 5,197 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll r = 1'000'000'000'000ll;
    vector<vector<ll>> tb(41);
    for(ll i = 2; i <= 1'000'000; i++){
        ll d = i * i;
        int cur = 2;
        while(d <= r){
            tb[cur++].emplace_back(d);
            d *= i;
        }
    }
    int Q;
    cin >> Q;
    while(Q--){
        ll n;
        cin >> n;
        int ans = 1;
        for(int i = 40; i >= 2; i--){
            if(binary_search(tb[i].begin(), tb[i].end(), n)){
                ans = i;
                break;
            }
        }
        cout << ans << '\n';
    }
}
0