結果
| 問題 | No.2057 Ising Model |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-08-27 01:05:07 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 361 bytes |
| 記録 | |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 14,976 KB |
| 最終ジャッジ日時 | 2026-05-01 12:11:20 |
| 合計ジャッジ時間 | 4,441 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
コンパイルメッセージ
Main.rb:6: warning: ambiguous first argument; put parentheses or a space even after `-` operator Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-` operator Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-` operator Syntax OK
ソースコード
N, A, B = gets.split.map(&:to_i)
if N % 2 == 0
if 2 * A > B
if A > B
puts -1 * A * (N - 1)
else
if N > 2
puts -1 * A * (N - 3) - B * 2
else
puts -1 * A - 2 * B
end
end
else
puts A * (N - 1) - B * N
end
else
if 2 * A > B
puts A * -1 * (N - 1) - B
else
puts A * (N - 1) - B * N
end
end
siman