結果
| 問題 |
No.84 悪の算盤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-28 20:42:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,097 bytes |
| コンパイル時間 | 1,583 ms |
| コンパイル使用メモリ | 165,980 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 12:45:23 |
| 合計ジャッジ時間 | 2,145 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
int R, C; cin >> R >> C;
if( not ( R >= C ) )
swap( R, C );
ll ans = 0;
if( ( R & 1 ) and ( C & 1 ) ){
if( R == C ){
int st = R - 1;
int ed = 2;
ans = 1LL * ( st + ed ) * ( R / 2 ) / 2 + 1;
} else{
int st = R - 2 + C - 2 + 2;
int ed = ( R - C / 2 * 2 ) - 2 + 1 + 2;
ans = 1LL * ( st + ed ) * ( C / 2 ) / 2 + ( R + 1 ) / 2;
}
} else if( not ( R & 1 ) and not ( C & 1 ) ){
if( R == C ){
int st = R - 1;
int ed = 1;
ans = 1LL * ( st + ed ) * ( R / 2 ) / 2;
} else{
int st = R - 2 + C - 2 + 2;
int ed = 0;
ans = 1LL * ( st + ed ) * ( C / 2 ) / 2;
}
} else{
if( R & 1 ){
int st = R - 2 + C - 2 + 2;
int ed = 0;
ans = 1LL * ( st + ed ) * ( ( C / 2 ) + 1 ) / 2;
} else{
int st = R - 2 + C - 2 + 2;
int ed = R - ( C / 2 - 1 ) * 2 - 2 + 1 + 2;
ans = 1LL * ( st + ed ) * ( C / 2 ) / 2 + ( R - C / 2 * 2 ) / 2;
}
}
cout << ans - 1 << endl;
return 0;
}