結果
| 問題 |
No.84 悪の算盤
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-06-15 15:29:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,545 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 87,588 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:53:22 |
| 合計ジャッジ時間 | 1,252 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
/*
No.84 悪の算盤
例示を怠らない事。
R != C のとき ans = (R*C+1)/2 - 1
R == C のとき
R == C == 1 のとき ans = 1 - 1
R == C == 2 のとき ans = 1 - 1
R == C == 3 のとき ans = 3 - 1
R == C == 4 のとき ans = 4 - 1
R == C == 5 のとき ans = 7 - 1
R == C == 6 のとき ans = 9 - 1
R == C == 7 のとき ans = 13 - 1
R == C == 8 のとき ans = 16 - 1
R == C == 9 のとき ans = 21 ^ 1
よって ans = (R*C + 3 )/4 - 1
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
ios_base::sync_with_stdio(0);
ll R, C; cin >> R >> C;
ll res;
if (R != C ){
res = (R*C + 1LL )/2LL - 1LL;
}else{ // if (R == C )
res = (R*C + 3LL )/4LL - 1LL;
} // end if
cout << res << endl;
return 0;
}
ty70