
Одна продуктовая сеть в рамках акции выдает скидочные купоны двух видов. По первому купону можно
получить скидку в 8% от стоимости покупки, но не более 100 рублей. По второму купону можно получить скидку в 5% от стоимости покупки без других ограничений. Предъявлять можно только один купон, разделять покупку на части нельзя. Покупатель делает покупку на p рублей. У него есть оба купона. Напишите программу, которая вычислит максимальный размер скидки, которую покупатель сможет получить. Формат входных данных На вход подается одно целое число — размер покупки в рублях. Число не превосходит 10000. Формат выходных данных Вывести одно число — размер скидки в рублях. Ответ может оказаться не целым. Методика проверки Программа проверяется на 20 тестах. Прохождение каждого теста оценивается в 1 балл. Тесты из условия задачи при проверке не используются. Sample Input 1: 810 Sample Output 1: 64.8 Sample Input 2: 1530 Sample Output 2: 100 Sample Input 3: 10000 Sample Output 3: 500

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

Ответ:
a = int(input())
if a <= 1250:
b = a / 100 * 8
elif a > 1250 and a <= 2000:
b = 100
elif a > 2000:
b = a / 100 * 5
print(b)



Ответ:
#include <iostream>
using std::cin;
using std::cout;
int main() {
// put your code here
double p,S1,S2;
cin>>p;
S1=p*8/100;
if(S1>100)S1=100;
S2=p*5/100;
if(S1>S2) cout<<S1;
else cout<<S2;
Объяснение: С++



Problem Analysis
The problem requires us to calculate the maximum discount that a buyer can receive using the given coupons. There are two types of coupons: the first one offers an 8% discount on the purchase, but not exceeding 100 rubles, while the second one offers a 5% discount without any limit. The buyer can only use one coupon, and they cannot split the purchase into multiple parts.
To solve this problem, we can follow these steps: 1. Read the input, which is the purchase amount in rubles. 2. Calculate the discount using the first coupon. If the discount exceeds 100 rubles, limit it to 100 rubles. 3. Calculate the discount using the second coupon. 4. Compare the discounts calculated in steps 2 and 3, and output the maximum discount.
Let's proceed with writing the program in Python.
Plan
1. Read the input, which is the purchase amount in rubles. 2. Calculate the discount using the first coupon: - Calculate the discount amount by multiplying the purchase amount by 8%. - If the discount amount exceeds 100 rubles, set it to 100 rubles. 3. Calculate the discount using the second coupon: - Calculate the discount amount by multiplying the purchase amount by 5%. 4. Compare the discounts calculated in steps 2 and 3: - Output the maximum discount amount.Pseudocode
``` purchase_amount = read_input()first_coupon_discount = purchase_amount * 0.08 if first_coupon_discount > 100: first_coupon_discount = 100
second_coupon_discount = purchase_amount * 0.05
max_discount = max(first_coupon_discount, second_coupon_discount)
output(max_discount) ```
Let's implement this in Python.


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