Topic Links:
space=1&num=1725 "target=" _blank ">http://acm.timus.ru/problem.aspx?space=1&num=1725
Every fall, all movies is shown to a full house at one of the most popular cinema theatres in Yekaterinburg because Stude NTS like to spend their time sitting in a cosy chair and watching a movie instead of attending lectures and seminars. Unfortunately, the distance between the rows of seats in the cinema hall are small, and people constantly stumble over othe R people ' s feet as they get to their seats before the film exhibition. Entering the hall, a visitor chooses from which end of the row (left or right) he'll make his and his-to-his seat. He chooses it in such a, the number of people over whose feet he'll stumble would be minimal. If These numbers is equal for the left and right ends, the visitor chooses the end of the row which was closer to his seat . Student of the Department of Philosophy Vasya is a enthusiastic movie-goer and an equally enthusiastic hater of Mathemati Cs. He was the first to buy a ticket to the first exhibition of a new movie. When Vasya entered the hall and sat down with his seat, he saw, and seats in the row were still unoccupied. Vasya knew that by the time the exhibition started the hall would is full. Therefore, quite a number of other visitors would stumble over he feet while getting to their seats. Despite his hatred for mathematics, Vasya is able to instantly estimate the maximal number of people that would stumble O Ver his feet before the exhibition. Can do the same?
Inputthe only input line contains the total number of seats N in the row where Vasya is sitting and the number of His seat K (1≤ k ≤ n ≤ 50; n is even). These integers is separated with a space. The seats in the row is numbered starting with one. Outputoutput the maximal number of people who would stumble over Vasya ' s feet. Sample
The code is as follows:
#include <cstdio>int main () { int n, K; while (~SCANF ("%d%d", &n,&k)) { int ans; if (n = = 2)//on both sides { ans = 0; } else if (k <= n/2) { ans = n-2-k; } else { ans = k-3; } printf ("%d\n", ans); } return 0;}
URAL 1725. Sold out! (Math AH)