結果

問題 No.1156 Nada Picnic 2
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-07 19:07:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,182 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 77,024 KB
最終ジャッジ日時 2023-09-14 04:39:59
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 341 ms
77,024 KB
testcase_02 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

import itertools

if n == 1:
    for p in itertools.permutations(range(10), 8):
        a = str(p[0])+str(p[1])+str(p[2])
        b = str(p[3])+str(p[4])+str(p[5])
        c = str(p[1])+str(p[6])+str(p[2])+str(p[7])
        if a[0] == '0' or b[0] == '0' or c[0] == '0':
            continue
        if int(a)+int(b) == int(c):
            print(c)
            exit()
elif n == 2:
    for p in itertools.permutations(range(10), 10):
        a = str(p[0])+str(p[0])+str(p[1])+str(p[2])
        b = str(p[3])+str(p[4])+str(p[5])+str(p[6])
        c = str(p[7])+str(p[8])+str(p[1])+str(p[2])+str(p[9])
        if a[0] == '0' or b[0] == '0' or c[0] == '0':
            continue
        if int(a)+int(b) == int(c):
            print(c)
            exit()
else:
    for p in itertools.permutations(range(10), 10):
        a = str(p[0])+str(p[1])+str(p[2])+str(p[3])+str(p[4])+str(p[5])
        b = str(p[6])+str(p[3])+str(p[5])+str(p[7])+str(p[8])
        c = str(p[1])+str(p[2])+str(p[9])+str(p[4])+str(p[2])+str(p[9])
        if a[0] == '0' or b[0] == '0' or c[0] == '0':
            continue
        if int(a)+int(b) == int(c):
            print(c)
            exit()
0