結果
問題 | No.1666 累乗数 |
ユーザー | Kiri8128 |
提出日時 | 2021-09-03 23:07:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,625 ms / 2,000 ms |
コード長 | 1,279 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,440 KB |
最終ジャッジ日時 | 2024-12-15 17:13:42 |
合計ジャッジ時間 | 21,858 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 89 ms
75,904 KB |
testcase_01 | AC | 520 ms
76,416 KB |
testcase_02 | AC | 519 ms
76,772 KB |
testcase_03 | AC | 519 ms
76,416 KB |
testcase_04 | AC | 526 ms
76,544 KB |
testcase_05 | AC | 1,589 ms
76,672 KB |
testcase_06 | AC | 1,622 ms
76,672 KB |
testcase_07 | AC | 1,625 ms
76,976 KB |
testcase_08 | AC | 1,616 ms
77,008 KB |
testcase_09 | AC | 714 ms
76,928 KB |
testcase_10 | AC | 770 ms
76,672 KB |
testcase_11 | AC | 776 ms
77,440 KB |
testcase_12 | AC | 761 ms
77,032 KB |
testcase_13 | AC | 1,487 ms
76,780 KB |
testcase_14 | AC | 1,481 ms
76,672 KB |
testcase_15 | AC | 1,486 ms
77,056 KB |
testcase_16 | AC | 1,502 ms
76,800 KB |
testcase_17 | AC | 965 ms
77,064 KB |
testcase_18 | AC | 1,124 ms
77,360 KB |
testcase_19 | AC | 931 ms
76,672 KB |
ソースコード
def sqrt(n, k = 2): if n == 0: return 0 l = k - 1 if not n: return 0 y = 1 << (n.bit_length() + l) // k x = y + 1 while y < x: x = y y = (l * x + n // (x ** l)) // k return x def cnt(n): s = 1 for b, w in WW1: s += w * (sqrt(n, b) - 1) for b, w in WW2: if n >= 2 ** b: s += w return s WW = [(2, 1), (3, 1), (5, 1), (6, -1), (7, 1), (10, -1), (11, 1), (13, 1), (14, -1), (15, -1), (17, 1), (19, 1), (21, -1), (22, -1), (23, 1), (26, -1), (29, 1), (30, 1), (31, 1), (33, -1), (34, -1), (35, -1), (37, 1), (38, -1), (39, -1), (41, 1), (42, 1), (43, 1), (46, -1), (47, 1), (51, -1), (53, 1), (55, -1), (57, -1), (58, -1), (59, 1)] WW1 = [(2, 1), (3, 1), (5, 1), (6, -1), (7, 1), (10, -1), (11, 1), (13, 1), (14, -1), (15, -1), (17, 1), (19, 1), (21, -1), (22, -1), (23, 1), (26, -1), (29, 1), (30, 1), (31, 1), (33, -1), (34, -1), (35, -1), (37, 1), (38, -1)] WW2 = [(39, -1), (41, 1), (42, 1), (43, 1), (46, -1), (47, 1), (51, -1), (53, 1), (55, -1), (57, -1), (58, -1), (59, 1)] T = int(input()) for _ in range(T): K = int(input()) l, r = 0, 10 ** 18 while r - l > 1: m = l + r >> 1 if cnt(m) < K: l = m else: r = m print(r)