結果

問題 No.3024 等式
ユーザー cielciel
提出日時 2017-04-22 22:25:34
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 443 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 19,600 KB
最終ジャッジ日時 2023-09-28 21:33:32
合計ジャッジ時間 9,165 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
15,256 KB
testcase_01 AC 92 ms
15,276 KB
testcase_02 AC 97 ms
15,400 KB
testcase_03 AC 96 ms
15,160 KB
testcase_04 AC 91 ms
15,104 KB
testcase_05 AC 93 ms
15,244 KB
testcase_06 AC 324 ms
15,248 KB
testcase_07 AC 333 ms
15,260 KB
testcase_08 AC 343 ms
15,240 KB
testcase_09 AC 90 ms
15,152 KB
testcase_10 AC 92 ms
15,204 KB
testcase_11 AC 116 ms
15,264 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,&block)
	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