結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー えんてぃてぃえんてぃてぃ
提出日時 2023-12-20 14:01:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-12-20 14:01:41
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 255 ms
10,112 KB
testcase_05 AC 257 ms
10,112 KB
testcase_06 AC 243 ms
10,112 KB
testcase_07 AC 251 ms
10,112 KB
testcase_08 AC 252 ms
10,112 KB
testcase_09 AC 249 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

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