結果
問題 | No.5003 物理好きクリッカー |
ユーザー |
|
提出日時 | 2018-12-02 16:09:19 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 548 ms / 10,000 ms |
コード長 | 2,215 bytes |
コンパイル時間 | 62 ms |
実行使用メモリ | 27,512 KB |
スコア | 21,672,124,448 |
平均クエリ数 | 10000.00 |
最終ジャッジ日時 | 2021-07-19 07:54:27 |
合計ジャッジ時間 | 21,490 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
コンパイルメッセージ
Main.rb:68: warning: assigned but unused variable - score Main.rb:115: warning: assigned but unused variable - ans Syntax OK
ソースコード
#!/usr/bin/env rubydef gen_specialspecial = ''i = rand(200)while special.size < 10000special += 'N' * ispecial += 'BFS'[rand(3)]i = rand(100) + 100endspecial[0,10000]endclass Buildingattr_accessor :name, :cpsdef initialize(name, cps, price)@name = name@cps = cps@price = priceenddef price(n)r = @price * (6 ** n)m = 5 ** n(r + m - 1) / menddef rprice(n, pow)@price * 10 ** powendendBUILDINGS = [Building.new('hand', 1, 150),Building.new('lily', 10, 2000),Building.new('factory', 120, 30000),Building.new('casino', 2000, 600000),Building.new('grimoire', 25000, 10000000),]def solve(special)cookie = 0num_buildings = [0] * 5pow_buildings = [1] * 5fever_turns = 0cmds = []10000.times do |t|choices = []5.times do |i|building = BUILDINGS[i]nb = num_buildings[i]pb = pow_buildings[i]pr = building.price(nb)cps_per_price = building.cps.to_f * pb / prscore = cps_per_price / Math.log(pr)choices << [score, pr, "buy", i]pr = building.rprice(nb, pb)cps_per_price = building.cps.to_f * pb * nb / prscore = cps_per_price / Math.log(pr)choices << [score, pr, "reinforce", i]endscore, pr, cmd, bi = choices.sort[-1]#STDERR.puts "#{cmd} #{bi}"if pr <= cookiecmds << "#{cmd} #{BUILDINGS[bi].name}"cookie -= prif cmd == "buy"num_buildings[bi] += 1elsif cmd == "reinforce"pow_buildings[bi] *= 2elseraiseendelsecmds << "click"cookie += 1endin_fever = fever_turns > 0 ? 7 : 1fever_turns -= 15.times do |i|building = BUILDINGS[i]cookie += building.cps * pow_buildings[i] * num_buildings[i] * in_feverendcase special[t]when 'B'cookie += (cookie + 99) / 100when 'F'fever_turns = 20when 'S'endendSTDERR.puts cookiecmdsendif ARGV[0] == '--test'solve(gen_special)elsegetsspecial = gets.chompcmds = solve(special)10000.times do |t|puts cmds[t]STDOUT.flushans = gets.chompendend