結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー Yuto_kyopro0731
提出日時 2023-12-02 15:34:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 152,624 KB
最終ジャッジ日時 2024-11-19 21:32:02
合計ジャッジ時間 24,406 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 2 RE * 1 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

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(item for item in perm)
        X = int(s)
        if X%M==0:
            return X
        elif M - ((X*10)%M) < 10:
            return X*10 + M - ((X*10)%M)

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