結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー Yuto_kyopro0731Yuto_kyopro0731
提出日時 2023-12-02 15:26:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 586 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,184 KB
最終ジャッジ日時 2023-12-02 15:26:34
合計ジャッジ時間 3,807 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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