結果
| 問題 |
No.8024 等式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-22 22:48:36 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 453 bytes |
| コンパイル時間 | 60 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 17,408 KB |
| 最終ジャッジ日時 | 2024-07-21 16:24:02 |
| 合計ジャッジ時間 | 8,588 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 TLE * 1 -- * 10 |
コンパイルメッセージ
Main.rb:19: warning: assigned but unused variable - n Syntax OK
ソースコード
#!/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|
(puts :YES;exit) if l==0
dfs(a[i+1..-1]){|r|
(puts :YES;exit) if r==0
yield l+r
yield l-r
yield l*r
yield l.is_a?(Rational) || r.is_a?(Rational) ? l/r : Rational(l,r)
}
}
}
end
n,*a=`dd`.split.map(&:to_i)
a.permutation{|b|
dfs(b).each{|e|
(puts :YES;exit) if e==0
}
}
puts :NO