結果
問題 |
No.1953 8
|
ユーザー |
![]() |
提出日時 | 2022-05-20 23:30:07 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-20 09:57:08 |
合計ジャッジ時間 | 5,454 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
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)