結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー Yuto_kyopro0731
提出日時 2023-12-02 15:26:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 586 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-11-19 21:31:29
合計ジャッジ時間 3,657 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

def culc(M,d):
    D = []
    for i in range(9):
        if d[i]!=0:
            for _ in range(d[i]):
                D.append(str(i+1))
    
    for perm in permutations(D):
        s = ''.join(perm)
        X = int(s)
        if X%M==0:
            return X
    
    D.append(0)
    for perm in permutations(D):
        s = ''.join(item for item in perm)
        X = int(s)
        if X%M==0:
            return X

T = int(input())

for i in range(T):
    M = int(input())
    d = list(map(int, input().split()))
    ans = culc(M,d)
    print(ans)
0