http://codeforces.com/problemset/problem/1163/A
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...
What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now nn cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.
Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are mm cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?
Could you help her with this curiosity?
You can see the examples and their descriptions with pictures in the "Note" section.
Input
The only line contains two integers nn and mm (2≤n≤10002≤n≤1000, 0≤m≤n0≤m≤n) — the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.
Output
Print a single integer — the maximum number of groups of cats at the moment Katie observes.
Examples
input
Copy
7 4
output
Copy
3
input
Copy
6 2
output
Copy
2
input
Copy
3 0
output
Copy
1
input
Copy
2 2
output
Copy
0
Note
In the first example, originally there are 77 cats sitting as shown below, creating a single group:
At the observed moment, 44 cats have left the table. Suppose the cats 22, 33, 55 and 77 have left, then there are 33 groups remaining. It is possible to show that it is the maximum possible number of groups remaining.
In the second example, there are 66 cats sitting as shown below:
At the observed moment, 22 cats have left the table. Suppose the cats numbered 33 and 66 left, then there will be 22 groups remaining ({1,2}{1,2}and {4,5}{4,5}). It is impossible to have more than 22 groups of cats remaining.
In the third example, no cats have left, so there is 11 group consisting of all cats.
In the fourth example, all cats have left the circle, so there are 00 groups.
题意:给出n个猫咪坐成一个圆,问去掉m个猫咪,最大能得到多少个猫集
做法:水题
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
if(m==0||m==1)
{
printf("1\n");
return 0;
}
int d=n/2;
if(n&1) d++;
if(m>=d) m=n-m;
printf("%d\n",m);
}