結果

問題 No.3024 等式
ユーザー zimphazimpha
提出日時 2017-03-31 23:54:13
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,119 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 77,940 KB
実行使用メモリ 91,928 KB
最終ジャッジ日時 2023-09-21 13:00:26
合計ジャッジ時間 12,952 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
82,796 KB
testcase_01 AC 131 ms
82,448 KB
testcase_02 AC 188 ms
84,024 KB
testcase_03 AC 170 ms
84,008 KB
testcase_04 AC 137 ms
82,676 KB
testcase_05 AC 133 ms
82,672 KB
testcase_06 AC 546 ms
91,928 KB
testcase_07 AC 570 ms
90,508 KB
testcase_08 AC 554 ms
91,208 KB
testcase_09 AC 355 ms
88,152 KB
testcase_10 AC 265 ms
87,528 KB
testcase_11 AC 271 ms
85,888 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import *

n = int(raw_input())
a = map(int, raw_input().split(' ' ))

def gao(a, v):
    for x in a:
        v[x] = 1
    n = len(a)
    for i in xrange(n):
        for j in xrange(n):
            if i == j:
                continue
            t = []
            for k in xrange(n):
                if k == i or k == j:
                    continue
                t.append(a[k])
            t.append(0)
            t[-1] = a[i] - a[j]
            gao(t, v)
            t[-1] = a[i] + a[j]
            gao(t, v)
            t[-1] = a[i] * a[j]
            gao(t, v)
            if a[j]:
                t[-1] = a[i] / a[j]
                gao(t, v)

for mask in xrange(1 << n):
    x = []
    y = []
    for i in xrange(n):
        if (mask >> i & 1):
            x.append(Fraction(a[i], 1))
        else:
            y.append(Fraction(a[i], 1))
    sx = {}
    sy = {}
    if not len(x) or not len(y):
        continue
    if n == 7 and min(len(x), len(y)) == 1:
        continue
    gao(x, sx)
    gao(y, sy)
    for v in sx:
        if v in sy:
            print 'YES'
            exit(0)
print 'NO'
0