結果

問題 No.84 悪の算盤
ユーザー htensai
提出日時 2019-12-30 17:47:08
言語 Java
(openjdk 23)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 2,494 ms
コンパイル使用メモリ 75,356 KB
実行使用メモリ 41,544 KB
最終ジャッジ日時 2024-11-09 00:44:26
合計ジャッジ時間 3,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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