結果

問題 No.1213 sio
ユーザー e869120e869120
提出日時 2021-02-26 11:19:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 64,324 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 23:45:18
合計ジャッジ時間 1,649 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

long long solve(long long H, long long W) {
	if (H > W) swap(H, W);
	if (H == 1) return (W / 4);
	if (H == 2) return 0;
	if (H == 3) return (W / 4);
	if (H % 4 == 0) {
		if (W % 2 == 0) return 0;
		return (H / 4);
	}
	if (H % 4 == 1) {
		if (W % 2 == 0) return (W / 4);
		return (W / 4) + (H / 4);
	}
	if (H % 4 == 2) {
		if (W % 2 == 0) return 0;
		return (H / 4);
	}
	if (H % 4 == 3) {
		if (W % 2 == 0) return (W / 4);
		if (W % 4 == 1) return (W / 4) + (H / 4);
		return (W / 4) + (H / 4) + 2;
	}
	return -1;
}

int main() {
	long long H, W;
	cin >> H >> W;
	cout << solve(H, W) << endl;
	return 0;
}
0