結果

問題 No.540 格子点と経路
ユーザー kurenai3110kurenai3110
提出日時 2017-07-01 00:17:47
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 70,956 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-05 00:19:34
合計ジャッジ時間 1,458 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <cstdlib>
using namespace std;

int main()
{
	int W, H; cin >> W >> H;

	int m = min(W, H);
	int M = max(W, H);
	
	long long cost = 0;
	int x = 3;
	for (int i = 1; i <= m; i++) {
		cost += x;
		if (i % 2 == 0)x += 4;
	}


	for (int i = 0; i < M-m; i++)cost += m + m%2;

	cout << cost+(M>m && m%2==0) << endl;
	
	return 0;
}
0