結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー えんてぃてぃえんてぃてぃ
提出日時 2023-12-20 13:38:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 540 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 16,788 KB
最終ジャッジ日時 2023-12-20 13:38:30
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
16,788 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

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) < 17:  # 17桁にする
		ans += "9"
	ans = int(ans)
	
	remainder = ans % M
	ans -= remainder
	
	while check_ans(ans, d) == False:
		ans -= M
		if ans < 0:
			assert False
	
	print(ans)
0