結果
問題 | No.1666 累乗数 |
ユーザー | rlangevin |
提出日時 | 2023-09-06 12:27:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 910 ms / 2,000 ms |
コード長 | 975 bytes |
コンパイル時間 | 495 ms |
コンパイル使用メモリ | 87,124 KB |
実行使用メモリ | 253,232 KB |
最終ジャッジ日時 | 2023-09-06 12:27:53 |
合計ジャッジ時間 | 20,085 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 848 ms
252,804 KB |
testcase_01 | AC | 866 ms
252,608 KB |
testcase_02 | AC | 865 ms
252,572 KB |
testcase_03 | AC | 851 ms
252,560 KB |
testcase_04 | AC | 866 ms
252,940 KB |
testcase_05 | AC | 853 ms
252,516 KB |
testcase_06 | AC | 847 ms
252,616 KB |
testcase_07 | AC | 863 ms
252,400 KB |
testcase_08 | AC | 839 ms
252,648 KB |
testcase_09 | AC | 899 ms
252,600 KB |
testcase_10 | AC | 910 ms
252,496 KB |
testcase_11 | AC | 898 ms
252,372 KB |
testcase_12 | AC | 869 ms
252,552 KB |
testcase_13 | AC | 899 ms
252,452 KB |
testcase_14 | AC | 872 ms
252,580 KB |
testcase_15 | AC | 889 ms
253,232 KB |
testcase_16 | AC | 871 ms
252,720 KB |
testcase_17 | AC | 894 ms
252,556 KB |
testcase_18 | AC | 879 ms
252,748 KB |
testcase_19 | AC | 886 ms
252,856 KB |
ソースコード
import sys input = sys.stdin.readline from bisect import * def isqrt(n): yes = 1 no = 10 ** 9 + 5 while no - yes != 1: mid = (yes + no)//2 if mid * mid <= n: yes = mid else: no = mid return yes inf = 10 ** 18 + 5 S = set() for n in range(3, 65): now = 2 while True: v = now ** n if v >= inf: break v2 = isqrt(v) ** 2 if v != v2: S.add(now ** n) now += 1 S = sorted(list(S)) T = int(input()) for _ in range(T): K = int(input()) yes = inf no = 0 while yes - no != 1: mid = (yes + no)//2 i2 = isqrt(mid) ans = -1 if i2 ** 2 == mid: ans = mid else: ans = (i2 + 1) ** 2 i3over = bisect_left(S, mid) if S[i3over] == mid: i3over += 1 if i2 + i3over >= K: yes = mid else: no = mid print(yes)