結果
| 問題 | No.3236 累乗数大好きbot |
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-08-15 22:17:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 211 ms / 4,000 ms |
| コード長 | 1,315 bytes |
| コンパイル時間 | 5,380 ms |
| コンパイル使用メモリ | 333,936 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-15 22:17:48 |
| 合計ジャッジ時間 | 11,337 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;
typedef long long ll;
ll sqrt_ll(ll n, int k) {
auto check = [&](ll mid) {
ll x = 1;
rep(i, 0, k) {
x *= mid;
if (x > n) return false; // mid^k > n
}
return true;
};
auto binary = [&]() {
ll L = 0, R = 3000000010;
ll mid = (L + R) / 2;
while (R - L > 1) {
if (check(mid))
L = mid;
else
R = mid;
mid = (L + R) / 2;
}
return L; // L-true R-false
};
ll ret = binary();
return ret;
}
void solve() {
ll n;
cin >> n;
int ans = 1;
for (int k = 2; k <= 6; k++) {
ll x = sqrt_ll(n, k);
ll y = 1;
rep(_, 0, k) { y *= x; }
if (y == n) ans = k;
}
for (int x = 2; x <= 100; x++) {
int cnt = 0;
ll cur = 1;
while (cur < n) {
cur *= x;
cnt++;
}
if (cur == n) {
ans = max(ans, cnt);
}
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) solve();
}
SnowBeenDiding