結果

問題 No.84 悪の算盤
ユーザー htensaihtensai
提出日時 2019-12-30 17:47:08
言語 Java19
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 70,504 KB
実行使用メモリ 56,452 KB
最終ジャッジ日時 2023-08-08 17:42:12
合計ジャッジ時間 4,768 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,228 KB
testcase_01 AC 118 ms
56,388 KB
testcase_02 AC 117 ms
55,772 KB
testcase_03 AC 118 ms
55,932 KB
testcase_04 AC 118 ms
55,824 KB
testcase_05 AC 117 ms
56,000 KB
testcase_06 AC 118 ms
55,872 KB
testcase_07 AC 118 ms
55,780 KB
testcase_08 AC 118 ms
56,452 KB
testcase_09 AC 118 ms
56,056 KB
testcase_10 AC 118 ms
55,968 KB
testcase_11 AC 117 ms
56,060 KB
testcase_12 AC 119 ms
56,444 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