結果
| 問題 |
No.1666 累乗数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 22:18:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,116 bytes |
| コンパイル時間 | 1,929 ms |
| コンパイル使用メモリ | 169,476 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-15 14:10:16 |
| 合計ジャッジ時間 | 3,013 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "debug.hpp"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
ll K;
vector<ll> primes;
void calc_init() {
vector<ll> check(100, 1);
for (ll i = 2; i < 100; i++) {
if (check[i]) {
primes.push_back(i);
for (ll j = 2; i * j < 100; j++) {
check[i * j] = 0;
}
}
}
}
bool isOK(ll key) {
ll max = sqrt(key);
ll cnt = 1;
for (ll p: primes) {
double temp = pow(key, 1.0 / ((double) p));
ll temp2 = (ll) temp;
if (pow(temp2 + 1, p) <= key) temp2++;
if (temp2 <= 1) break;
cnt += (temp2 - 1);
}
return (cnt >= K);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
calc_init();
debug(primes);
ll T; cin >> T;
for (ll t = 0; t < T; t++) {
cin >> K;
// N以下の累乗数はK個以下?
ll ok = 2e18, ng = 0;
while (abs(ok - ng) > 1) {
ll mid = (ok + ng) / 2;
if (isOK(mid)) ok = mid;
else ng = mid;
}
cout << ok << '\n';
}
return 0;
}