题目大意
一个有基佬气息的人想让他左或有有邻居,知道邻居数,但不知道位置,求最少和最大能选几个位置。
题解
显然k=0 ans:0,0
k=n min=0;
else min=1;
max=max(n-k,2*k)(一个邻居有两个位置)。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
char ch=getchar();int f=0;
while(ch<'0'||ch>'9') ch=getchar();
while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
return f;
}
int main()
{
int n=read(),k=read();
if(k==0)
{
cout<<"0 ";
}
else if(n<=k)
{
cout<<"0 0";
return 0;
}
else
cout<<"1 ";
cout<<min(n-k,k*2);
}