
После обучения Архимед и Эратосфен переписывались еще много лет. Помогите определить, сколько денег
нужно заплатить за отправку бандероли в древней Греции, если известно, что за бандероль весом до 50 грамм взимается 10 драхм (дренегреческая валюта), а за каждые следующие полные или неполные 50 грамм еще по 5 драхм. Напишите программу, вычисляющую, какое наименьшее число монет по 10, 4 и 1 драхме надо заплатить за отправку бандероли весом w грамм.(Free Pascal)

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

------------------------
program aaa;
const n=50;
var w, c, x, d10, d4, d1: integer;
begin
writeln ('Введите вес бандероли');
readln (w);
if w <= n
then c:=10
else
if w mod n = 0
then c:=10+((w div n)-1)*5
else c:=10+5+((w div n)-1)*5;
d10:= c div 10;
d4:= (c-10*d10) div 4;
d1:= (c-d10*10-d4*4);
writeln ('стоимость бандероли: ',c,' драхм');
writeln;
writeln ('для оплаты нужно не менее');
writeln (d10:10,' монет по 10 драхм');
writeln (d4:10,' монет по 4 драхмы');
writeln (d1:10,' монет по 1 драхме');
end.
------------------
Результат работы программы:
Введите вес бандероли 100
стоимость бандероли: 15 драхм
для оплаты нужно не менее
1 монет по 10 драхм
1 монет по 4 драхмы
1 монет по 1 драхме



To calculate the minimum number of coins needed to pay for sending a package weighing w grams to ancient Greece, we can use the following approach:
1. Determine the weight of the package in 50-gram increments. 2. Calculate the number of 50-gram increments. 3. Calculate the number of 10-drachma coins needed for the 50-gram increments. 4. Calculate the remaining weight after accounting for the 50-gram increments. 5. Calculate the number of 5-drachma coins needed for the remaining weight. 6. Calculate the number of 1-drachma coins needed for the remaining weight.
Here's a Free Pascal program that implements this logic:
```pascal program CalculateCoins;
var w, weight, coins10, coins5, coins1: integer;
begin // Read the weight of the package in grams write('Enter the weight of the package in grams: '); readln(w);
// Calculate the number of 50-gram increments weight := w div 50;
// Calculate the number of 10-drachma coins needed for the 50-gram increments coins10 := weight * 10;
// Calculate the remaining weight after accounting for the 50-gram increments weight := w mod 50;
// Calculate the number of 5-drachma coins needed for the remaining weight coins5 := weight div 10 * 5;
// Calculate the number of 1-drachma coins needed for the remaining weight coins1 := weight mod 10;
// Output the minimum number of coins needed writeln('Minimum number of coins needed:'); writeln('10-drachma coins: ', coins10); writeln('5-drachma coins: ', coins5); writeln('1-drachma coins: ', coins1); end. ```
Please note that this program assumes that the weight of the package is a positive integer value.


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