結果

問題 No.1156 Nada Picnic 2
ユーザー neko_the_shadowneko_the_shadow
提出日時 2020-08-25 13:22:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,074 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 75,776 KB
最終ジャッジ日時 2024-04-24 04:23:48
合計ジャッジ時間 1,105 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
75,520 KB
testcase_01 AC 131 ms
75,264 KB
testcase_02 AC 113 ms
75,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n = int(input())
if n == 1:
    for a, b, c, d, e, f, g, h in itertools.permutations(range(10), r=8):
        if b == 0:
            continue
        x =          100*a + 10*b + c
        y =          100*d + 10*e + f
        z = 1000*b + 100*g + 10*h + b
        if x+y == z:
            print(z)
            exit(0)

if n == 2:
    for a, b, c, d, e, f, g, h, i, j in itertools.permutations(range(10)):
        if a == 0 or d == 0 or h == 0:
            continue
        x =           1000*a + 100*a + 10*b + c
        y =           1000*d + 100*e + 10*f + g
        z = 10000*h + 1000*i + 100*b + 10*c + j
        if x+y == z:
            print(z)
            exit(0)

if n == 3:
    for c, e, g, h, i, n, p, r, s, t in itertools.permutations(range(10)):
        if s == 0 or e == 0 or p == 0:
            continue
        x = 100000*s + 10000*p + 1000*r + 100*i + 10*n + g
        y =            10000*e + 1000*i + 100*g + 10*h + t
        z = 100000*p + 10000*i + 1000*c + 100*n + 10*i + c
        if x+y == z:
            print(z)
            exit(0)
0