結果
| 問題 |
No.1666 累乗数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 21:33:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,164 bytes |
| コンパイル時間 | 1,958 ms |
| コンパイル使用メモリ | 168,800 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-15 10:26:07 |
| 合計ジャッジ時間 | 3,109 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 19 |
ソースコード
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
vll P = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61 };
bool isOK(ll index, ll key) {
ll k = 1;
rep(p, P.size()) {
ll D = pow(index, double(1) / double(P[p]));
k += (D-1);
}
return (k < key);
}
// 汎用的な二分探索のテンプレ
ll binary_search(ll key) {
ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
ll ok = 1e18; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
/* ok と ng のどちらが大きいかわからないことを考慮 */
while (abs(ok - ng) > 1) {
ll mid = (ok + ng) / 2;
cout << "";
if (!isOK(mid, key)) ok = mid;
else ng = mid;
}
return ok;
}
int main() {
ll T;
cin >> T;
rep(t, T) {
ll N;
cin >> N;
cout << binary_search(N) << endl;
}
}