結果

問題 No.3024 等式
ユーザー cielciel
提出日時 2017-04-22 22:26:11
言語 Ruby
(3.2.2)
結果
TLE  
実行時間 -
コード長 436 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 19,708 KB
最終ジャッジ日時 2023-09-28 21:33:44
合計ジャッジ時間 8,880 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
15,288 KB
testcase_01 AC 91 ms
15,300 KB
testcase_02 AC 93 ms
15,380 KB
testcase_03 AC 93 ms
15,444 KB
testcase_04 AC 94 ms
15,124 KB
testcase_05 AC 87 ms
15,260 KB
testcase_06 AC 308 ms
15,196 KB
testcase_07 AC 320 ms
15,260 KB
testcase_08 AC 333 ms
15,312 KB
testcase_09 AC 88 ms
15,308 KB
testcase_10 AC 91 ms
15,280 KB
testcase_11 AC 113 ms
15,328 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def dfs(a)
	return to_enum(:dfs,a) if !block_given?
	yield a[0] if a.size<2
	(a.size-1).times{|i|
		dfs(a[0..i]){|l|
			dfs(a[i+1..-1]){|r|
				yield l+r
				yield l-r
				yield l*r
				yield l.is_a?(Rational) || r.is_a?(Rational) ? l/r : Rational(l,r) if r!=0
			}
		}
	}
end

n,*a=`dd`.split.map(&:to_i)
(3..n).each{|q|
	a.permutation(q){|b|
		dfs(b).each{|e|
			if e==0
				puts :YES
				exit
			end
		}
	}
}
puts :NO
0