
У Васи ровно N друзей. Он пишет на листе целое число M, затем каждый из друзей берет листок и
либо добавляет единицу к написанному числу, либо отнимает единицу, после чего передаёт листок дальше. Может ли в результате получиться число K? Напишите программу, которая по заданным числам M, N, K даёт ответ. Входные данные В первой строке 3 целых числа через пробел: M – число, которое написал Вася, N − количество друзей, число K (0 ≤ M, N, K ≤ 109). Выходные данные На выходе должно быть «YES» в случае ответа «да» и «NO» в противном случае

Ответы на вопрос

Ответ:
NM->MK->в результате получилось K->No



Answer in detail. Vasya has exactly N friends. He writes an integer M on a sheet of paper, then each of his friends takes the sheet and either adds one to the written number, or subtracts one, and then passes the sheet on. Can the number K be obtained as a result? Write a program that gives an answer for the given numbers M, N, K. Input data In the first line, 3 integers separated by a space: M - the number that Vasya wrote, N - the number of friends, the number K (0 ≤ M, N, K ≤ 109). Output data The output should be "YES" in case of answer "yes" and "NO" in the opposite case.
This is a translation from Russian to English of your text. You can use online tools like Google Translate, Yandex Translate, or Translate.com to translate text, words, phrases, or documents between different languages. Here is a possible program in Python that solves the problem:
```python # Read the input data M, N, K = map(int, input().split())
# Initialize a variable to store the answer answer = "NO"
# Check if the number K can be obtained by adding or subtracting one from M N times # This is equivalent to checking if the absolute difference between M and K is even and less than or equal to N if abs(M - K) % 2 == 0 and abs(M - K) <= N: # If yes, then the answer is "YES" answer = "YES"
# Print the answer print(answer) ```


Похожие вопросы







Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili