結果
| 問題 |
No.8024 等式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-22 23:19:05 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 484 bytes |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 17,664 KB |
| 最終ジャッジ日時 | 2024-07-21 16:30:33 |
| 合計ジャッジ時間 | 8,369 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 TLE * 1 -- * 10 |
コンパイルメッセージ
Main.rb:21: 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
next if l<0
dfs(a[i+1..-1]){|r|
(puts :YES;exit) if r==0
next 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