結果

問題 No.3024 等式
ユーザー TsubajiroTsubajiro
提出日時 2023-08-04 20:44:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2024-04-22 18:57:00
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,564 KB
testcase_01 WA -
testcase_02 AC 37 ms
52,896 KB
testcase_03 AC 37 ms
53,196 KB
testcase_04 WA -
testcase_05 AC 40 ms
52,588 KB
testcase_06 AC 51 ms
63,872 KB
testcase_07 AC 50 ms
64,756 KB
testcase_08 AC 50 ms
63,676 KB
testcase_09 AC 39 ms
52,460 KB
testcase_10 AC 38 ms
53,060 KB
testcase_11 WA -
testcase_12 AC 101 ms
76,928 KB
testcase_13 AC 98 ms
76,928 KB
testcase_14 AC 100 ms
76,668 KB
testcase_15 AC 58 ms
67,036 KB
testcase_16 AC 41 ms
58,408 KB
testcase_17 AC 37 ms
52,868 KB
testcase_18 AC 101 ms
77,192 KB
testcase_19 AC 100 ms
76,912 KB
testcase_20 AC 55 ms
63,992 KB
testcase_21 WA -
testcase_22 AC 217 ms
78,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(a,cnt,end):
    if cnt==len(can)-2:
        return
    for c in range(4):
        if c==0:
            if a+can[cnt]==end:
                print("YES")
                exit()
            calc(a+can[cnt],cnt+1,end)
        elif c==1:
            if a-can[cnt]==end:
                print("YES")
                exit()
            calc(a-can[cnt],cnt+1,end)
        elif c == 2:
            if a * can[cnt] == end:
                print("YES")
                exit()
            calc(a * can[cnt], cnt + 1, end)
        elif c == 3:
            if a / can[cnt] == end:
                print("YES")
                exit()
            calc(a / can[cnt], cnt + 1, end)


N=int(input())
A=list(map(int, input().split()))
import itertools
for i in range(7,1<<N):
    cand=[]
    for j in range(N):
        if i>>j&1:
            cand.append(A[j])
    if len(cand)<3:
        continue
    C=list(itertools.permutations(cand))
    for can in C:
        calc(can[0],1,can[-1])
print("NO")
0