結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tenkyu9
提出日時 2018-03-25 03:00:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 79,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 04:49:54
合計ジャッジ時間 1,496 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
typedef long long int ll;

int main(){

	int n, k;
	cin >> n >> k;
	if(n==1){
		cout << 0 << endl;
	} else if(n%2==0){
		if(k==0 || k>n){
			cout << 0 << endl;
		} else {
			cout << n-2 << endl;
		}
	} else {
		if(k==n/2+1){
			cout << n-1 << endl;
		} else if(k==0 || k>n){
			cout << 0 << endl;
		} else {
			cout << n-2 << endl;
		}
	}

  return 0;
}
0