結果

問題 No.84 悪の算盤
コンテスト
ユーザー siman
提出日時 2015-01-10 22:11:19
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 539 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 50 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2026-04-30 17:46:50
合計ジャッジ時間 1,470 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

class A
  def initialize
    r, c = gets.chomp.split(' ').map(&:to_i)

    if r != c
      if c.even?
        puts (r * (c/2)) - 1
      else
        if r.even?
          puts (r * (c/2) + (r/2)) - 1
        else
          puts (r * (c/2) + (r/2)+1) - 1
        end
      end
    else
      if c.even?
        n = c/2
        puts (n/2.0 * (1.0 + (2 * n - 1))).to_i - 1
      else
        if c == 1
          puts 0
        else
          n = c/2
          puts (n/2.0 * (2.0 + 2.0 * n)).to_i
        end
      end
    end
  end
end

A.new
0