結果
問題 |
No.1213 sio
|
ユーザー |
![]() |
提出日時 | 2021-02-26 11:19:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 511 ms |
コンパイル使用メモリ | 64,792 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 00:41:27 |
合計ジャッジ時間 | 1,463 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 |
ソースコード
#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; }