結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー maspymaspy
提出日時 2020-04-10 00:53:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 579 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,436 KB
最終ジャッジ日時 2023-10-12 04:14:42
合計ジャッジ時間 3,808 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,912 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 16 ms
7,796 KB
testcase_03 AC 17 ms
7,836 KB
testcase_04 AC 16 ms
7,836 KB
testcase_05 AC 15 ms
7,964 KB
testcase_06 AC 16 ms
7,956 KB
testcase_07 AC 15 ms
7,720 KB
testcase_08 AC 15 ms
7,720 KB
testcase_09 AC 16 ms
7,788 KB
testcase_10 AC 15 ms
7,800 KB
testcase_11 AC 16 ms
7,840 KB
testcase_12 AC 16 ms
7,776 KB
testcase_13 AC 16 ms
7,808 KB
testcase_14 AC 16 ms
7,728 KB
testcase_15 AC 16 ms
7,824 KB
testcase_16 AC 16 ms
7,904 KB
testcase_17 AC 16 ms
7,836 KB
testcase_18 AC 16 ms
7,816 KB
testcase_19 AC 16 ms
7,828 KB
testcase_20 AC 16 ms
7,836 KB
testcase_21 AC 17 ms
7,788 KB
testcase_22 AC 16 ms
7,804 KB
testcase_23 AC 16 ms
7,836 KB
testcase_24 AC 16 ms
7,796 KB
testcase_25 AC 16 ms
7,836 KB
testcase_26 AC 16 ms
7,964 KB
testcase_27 AC 16 ms
7,840 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 17 ms
7,784 KB
testcase_31 AC 18 ms
7,768 KB
testcase_32 AC 16 ms
7,796 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 18 ms
7,836 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 22 ms
8,424 KB
testcase_43 AC 75 ms
8,340 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 28 ms
8,436 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 16 ms
7,968 KB
testcase_51 AC 16 ms
7,816 KB
testcase_52 AC 16 ms
7,788 KB
testcase_53 AC 16 ms
7,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

B = int(readline())
D_str = read().rstrip()
n = len(D_str)
D = int(D_str, B)


def f(B, n):
    """sum k=1,...,n k(B^k-B^{k-1})"""
    x = B ** n
    return (x * (n * B - n - 1) + 1) // (B - 1)


for k in range(n - 20, n + 20):
    if k < 0:
        continue
    #  k桁までの消費
    if f(B, k) >= D:
        break

rest = D - f(B, k - 1)
q, r = divmod(rest, k)
if r == 0:
    r += k
    q -= 1
num = B ** (k - 1) + q
num //= (B ** (k - r))
print(num % B)
0