結果
| 問題 |
No.2057 Ising Model
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-08-27 01:05:07 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 361 bytes |
| コンパイル時間 | 333 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-10-14 01:38:48 |
| 合計ジャッジ時間 | 5,926 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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