結果

問題 No.1156 Nada Picnic 2
ユーザー brthyyjp
提出日時 2021-07-07 19:10:33
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 635 ms / 2,000 ms
コード長 1,314 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 207 ms
コンパイル使用メモリ 85,208 KB
実行使用メモリ 80,796 KB
最終ジャッジ日時 2026-03-22 13:26:49
合計ジャッジ時間 1,955 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())

import itertools

if n == 1:
    for p in itertools.permutations(range(10), 7):
        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[1])
        if a[0] == '0' or b[0] == '0' or c[0] == '0':
            continue
        if int(a)+int(b) == int(c):
            #print(a)
            #print(b)
            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(a)
            #print(b)
            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[3])+str(p[9])+str(p[4])+str(p[3])+str(p[9])
        if a[0] == '0' or b[0] == '0' or c[0] == '0':
            continue
        if int(a)+int(b) == int(c):
            #print(a)
            #print(b)
            print(c)
            exit()
0