結果
| 問題 |
No.3316 Make 81181819 with only 0,1,or 8
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-10-31 23:51:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,160 bytes |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 77,464 KB |
| 最終ジャッジ日時 | 2025-10-31 23:52:05 |
| 合計ジャッジ時間 | 3,225 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 WA * 1 |
ソースコード
import sys
from functools import lru_cache
from collections import deque
LIST=[[] for i in range(8)]
LIST[0]=[(0,[])]
Q=[0,1,8]
for i in range(7):
SET=set()
for now,L in LIST[i-1]:
for q in Q:
if now+q in SET:
continue
SET.add(now+q)
LIST[i].append((now+q,L+[q]))
MAX=81181819
T=int(input())
for tests in range(T):
x=int(input())
a=MAX-x
ANS=[]
flag=0
for i in range(8):
#print("!",i)
Q=[(a,[0 for i in range(i)],0)]
Q=deque(Q)
while Q:
#print(Q)
x,ANS,now=Q.popleft()
if x==0:
flag=1
LANS=ANS[:]
break
for s,L in LIST[i]:
if x%10==s%10 and x>=s:
nex=x-s
ANS2=ANS[:]
for j in range(i):
ANS2[j]+=L[j]*(10**now)
Q.append((nex//10,ANS2,now+1))
if flag:
break
print(len(LANS))
for ans in LANS:
print(ans)
titia