結果

問題 No.84 悪の算盤
ユーザー ty70ty70
提出日時 2015-06-15 15:29:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,545 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 10:06:44
合計ジャッジ時間 1,212 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0