結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー えんてぃてぃ
提出日時 2023-12-20 14:01:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-19 21:40:46
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

from collections import Counter
def check_ans(ans, d) -> bool:
	c = Counter(str(ans))
	for i, count in enumerate(d, 1):
		if c[str(i)] < count:
			return False
	return True

for _ in range(n):
	M = int(input())
	d = list(map(int, input().split()))
	
	ans = ""
	for i, count in enumerate(d, 1):
		ans += str(i) * count
	
	while len(ans) < 18:  # 18桁にする
		ans += "9"
	ans = int(ans)
	
	remainder = ans % M
	ans -= remainder
	
	if check_ans(ans, d) == False:
		assert False
	
	print(ans)
0