結果

問題 No.84 悪の算盤
ユーザー htensaihtensai
提出日時 2019-12-30 17:47:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,276 KB
実行使用メモリ 41,560 KB
最終ジャッジ日時 2024-04-26 10:14:36
合計ジャッジ時間 4,227 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
40,096 KB
testcase_01 AC 125 ms
41,088 KB
testcase_02 AC 119 ms
40,696 KB
testcase_03 AC 125 ms
41,432 KB
testcase_04 AC 125 ms
41,560 KB
testcase_05 AC 120 ms
41,396 KB
testcase_06 AC 120 ms
41,380 KB
testcase_07 AC 120 ms
41,148 KB
testcase_08 AC 118 ms
41,556 KB
testcase_09 AC 107 ms
40,704 KB
testcase_10 AC 118 ms
41,328 KB
testcase_11 AC 120 ms
41,092 KB
testcase_12 AC 117 ms
41,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextInt();
        long w = sc.nextInt();
        long ans;
        if (h == w) {
            if (h % 2 == 0) {
                ans = h * w / 4 - 1;
            } else {
                ans = (h * w - 1) / 4;
            }
        } else {
            if (h % 2 == 0 || w % 2 == 0) {
                ans = h * w / 2 - 1;
            } else {
                ans = (h * w - 1) / 2;
            }
        }
        System.out.println(ans);
    }
}
0