結果

問題 No.84 悪の算盤
ユーザー recososo
提出日時 2020-02-13 10:52:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 165,840 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-05 08:34:46
合計ジャッジ時間 2,194 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll r,c;cin >> r >> c;
    ll x,y,z;
    if(r%2==0&&c%2==0){
        x=0;
        y=0;
        z=(r/2)*(c/2);
        if(r!=c){
            z*=2;
        }
    }
    else if(r%2==1&&c%2==1){
        x=1;
        z=(r/2)*(c/2);
        if(r!=c){
            y=r/2+c/2;
            z*=2;
        }
        else{
            y=r/2;
        }
    }
    else{
        if(r%2==1){
            swap(r,c);
        }
        x=0;
        y=r/2;
        z=(r/2)*(c/2)*2;
    }
    cout << x+y+z-1 << endl;
}
0