結果

問題 No.1953 8
ユーザー titiatitia
提出日時 2022-05-20 23:30:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2023-10-20 14:27:29
合計ジャッジ時間 5,456 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
10,016 KB
testcase_01 AC 50 ms
10,016 KB
testcase_02 AC 59 ms
10,016 KB
testcase_03 AC 48 ms
10,016 KB
testcase_04 AC 48 ms
10,016 KB
testcase_05 AC 49 ms
10,016 KB
testcase_06 AC 48 ms
10,016 KB
testcase_07 AC 49 ms
10,016 KB
testcase_08 AC 48 ms
10,016 KB
testcase_09 AC 49 ms
10,016 KB
testcase_10 AC 48 ms
10,016 KB
testcase_11 AC 49 ms
10,016 KB
testcase_12 AC 49 ms
10,016 KB
testcase_13 AC 51 ms
10,016 KB
testcase_14 AC 50 ms
10,016 KB
testcase_15 AC 51 ms
10,016 KB
testcase_16 AC 50 ms
10,016 KB
testcase_17 AC 49 ms
10,016 KB
testcase_18 AC 55 ms
10,016 KB
testcase_19 AC 54 ms
10,016 KB
testcase_20 AC 56 ms
10,016 KB
testcase_21 AC 58 ms
10,016 KB
testcase_22 AC 55 ms
10,016 KB
testcase_23 AC 54 ms
10,016 KB
testcase_24 AC 55 ms
10,016 KB
testcase_25 AC 60 ms
10,016 KB
testcase_26 AC 59 ms
10,016 KB
testcase_27 AC 59 ms
10,016 KB
testcase_28 AC 51 ms
10,016 KB
testcase_29 AC 51 ms
10,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

K=int(input())

A=[1,0,0,0,1,0,1,0,2,1]
SUM10=sum(A)

def uni_score(x):
    S=list(map(int,list(str(x))))

    ANS=0
    for s in S:
        ANS+=A[s]

    return ANS
def score(x):
    ANS=0

    while x>0 and x%10!=9:
        ANS+=uni_score(x)
        x-=1

    if x==0:
        return ANS
    elif x==9:
        return ANS+SUM10-1
    else:
        ANS+=(x//10+1)*SUM10-1

        return ANS+score(x//10)*10

#print(score(16))
#print(score(17))
#print(score(99193752409910740))


NOW=0

for i in range(1,1000):
    NOW+=uni_score(i)

    assert NOW==score(i)

OK=-1
NG=10**20

while NG>OK+1:
    mid=(OK+NG)//2

    if score(mid)>K:
        NG=mid
    else:
        OK=mid

for i in range(max(1,OK-10),OK+10):
    if score(i)==K:
        print(i)
        break
else:
    print(-1)
0