結果

問題 No.265 数学のテスト
ユーザー maimai
提出日時 2017-12-31 00:38:57
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 828 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 57,380 KB
最終ジャッジ日時 2023-08-23 11:14:55
合計ジャッジ時間 4,209 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 149 ms
29,084 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:30: warning: assigned but unused variable - x
Syntax OK

ソースコード

diff #

class Nyan
    attr_accessor :e
    def initialize(h={1=> 1})
        @e = h # 次数=>係数,
        return self
    end
    def *(z)
        y = self.clone
        h = {}
        z.e.each do |a|
            y.e.each do |b|
                d = a[0]+b[0]
                h[d] = h[d].to_i + a[1]*b[1]
            end
        end
        y.e = h
        return y
    end
    def +(z)
        y = self.clone
        z.e.each do |a|
            y.e[a[0]] = y.e[a[0]].to_i + a[1]
        end
        return y
    end
end


x = Nyan.new
def d(w)
    h={}
    w.e.each do |d,k|
        h[d-1] = k*d if d>0
    end
    r = Nyan.new
    r.e = h
    return r
end


gets
m = gets.to_i
str = gets.chomp

str.gsub!(/[0-9]+/,'Nyan.new(0=>\0)')
str.gsub!('{','(')
str.gsub!('}',')')

ans = eval(str)

puts (0..m).map{|e| ans.e[e].to_i}*" "

0