結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー Yuto_kyopro0731
提出日時 2023-12-02 15:27:48
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 595 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 67,148 KB
最終ジャッジ日時 2024-11-19 21:31:37
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 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))
    
    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)

'''
    for perm in permutations(D):
        s = ''.join(perm)
        X = int(s)
        if X%M==0:
            return X
    
'''
0