結果

問題 No.1953 8
ユーザー 👑 rin204rin204
提出日時 2022-05-20 22:37:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 60,096 KB
最終ジャッジ日時 2023-10-20 13:23:43
合計ジャッジ時間 5,239 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,068 KB
testcase_01 AC 43 ms
59,068 KB
testcase_02 AC 47 ms
60,096 KB
testcase_03 AC 44 ms
59,080 KB
testcase_04 AC 44 ms
59,080 KB
testcase_05 AC 43 ms
59,080 KB
testcase_06 AC 43 ms
59,080 KB
testcase_07 AC 44 ms
59,080 KB
testcase_08 AC 43 ms
59,080 KB
testcase_09 AC 44 ms
59,080 KB
testcase_10 AC 44 ms
59,080 KB
testcase_11 AC 44 ms
59,080 KB
testcase_12 AC 44 ms
59,080 KB
testcase_13 AC 45 ms
59,088 KB
testcase_14 AC 45 ms
59,940 KB
testcase_15 AC 43 ms
59,080 KB
testcase_16 AC 44 ms
59,080 KB
testcase_17 AC 45 ms
59,940 KB
testcase_18 AC 45 ms
59,940 KB
testcase_19 AC 46 ms
60,096 KB
testcase_20 AC 45 ms
59,940 KB
testcase_21 AC 45 ms
59,940 KB
testcase_22 AC 45 ms
59,940 KB
testcase_23 AC 46 ms
60,096 KB
testcase_24 AC 46 ms
60,096 KB
testcase_25 AC 45 ms
59,940 KB
testcase_26 AC 46 ms
60,096 KB
testcase_27 AC 46 ms
60,096 KB
testcase_28 AC 44 ms
59,080 KB
testcase_29 AC 44 ms
59,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

circle = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]

def f(S):
    S = str(S)
    ret = 0
    eq = 0
    cnt = 0
    s = int(S[0])
    for i in range(1, s):
        ret += circle[i]
        cnt += 1
    eq = circle[s]
    for s in S[1:]:
        s = int(s)
        ret *= 10
        ret += cnt * 6
        cnt *= 10
        ret += 5
        cnt += 9
        for i in range(s):
            cnt += 1
            ret += eq + circle[i]
        eq += circle[s]
    return ret + eq



k = int(input())
l = 0
r = 10 ** 18
while r - l > 1:
    mid = (l + r) // 2
    if f(mid) >= k:
        r = mid
    else:
        l = mid
if f(r) == k:
    print(r)
else:
    print(-1)
0