結果
問題 | No.8024 等式 |
ユーザー |
|
提出日時 | 2023-08-04 20:44:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 987 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 78,200 KB |
最終ジャッジ日時 | 2024-10-14 18:28:40 |
合計ジャッジ時間 | 3,219 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 4 |
ソースコード
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")