結果
問題 | No.265 数学のテスト |
ユーザー |
|
提出日時 | 2015-08-09 03:23:42 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 311 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 128 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 28,800 KB |
最終ジャッジ日時 | 2024-11-24 11:27:59 |
合計ジャッジ時間 | 5,569 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby class Array def -@ self.map(&:-@) end def +(other) m=[self.size,other.size].max m.times.map{|i|(self.size<=i ? 0 : self[i])+(other.size<=i ? 0 : other[i])} end def -(other) self+-other end def *(other) r=[] other.size.times{|i| r=r+i.times.map{0}.concat(self.map{|e|other[i]*e}) } r end end def d(a) a.size<=1 ? [0] : 1.step(a.size-1).map{|i|i*a[i]} end gets D=gets.to_i s=gets.chomp.gsub(/(\d+)/,'[\1]').gsub('x','[0,1]').gsub('d{','d(').gsub('}',')') A=s.count('d(')>10000 ? [0] : eval(s) puts A.concat((D+1-A.size).times.map{0}).join(' ') __END__ d{x}は最大10000回しか現れないので、10000回以上d{が存在したら確実に0である。