結果

問題 No.2239 Friday
ユーザー Kome_soudouKome_soudou
提出日時 2023-03-10 22:22:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 166,224 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 04:32:43
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	if(a == b)
	{
		if(a == 1) cout << 2 << endl;
		else cout << 0 << endl;
		return 0;
	}
	
	if(a < b) swap(a, b);
	int ans = 200;
	int c, d;
	for(int i = 0; i <= b; i++)
	{
		if(a - i < 0) continue;
		c = 2 * i; d = a + b - 2 * i;
		ans = min(ans, abs(c - d));
	}
	cout << ans << endl;
	return 0;
}
0