using System;
public class Program
{
public static void Main()
{
var rand = new Random();
int x = rand.Next(3, 10);
int t = 1200;
int count;
if (t % x == 0)
{
count = t / x;
}
else
{
count = t / x + 1;
}
int ans;
if (count % 20 == 0)
{
ans = count / 20;
}
else
{
ans = count / 20 + 1;
}
Console.WriteLine(ans.ToString());
}
}
Генерируем рандомное число от 3 до 10. Затем рассчитаем на сколько лекций он опоздает суммарно на 20 часов (т.е. 1200 минут). Разделим количество лекций, на которые он опоздал, на 20 с округлением вверх и получим ответ.
c:array[1..6] of integer=(1,5,10,50,100,500);
var
i:byte;
n,d:integer;
k:array[1..6] of integer;
begin
Write('Введите значение суммы: '); Read(n);
for i:=1 to 6 do k[i]:=0;
d:=n; i:=6;
while d>0 do begin
k[i]:=d div c[i];
d:=d mod c[i];
Dec(i)
end;
Write(n,' => ');
for i:=6 downto 1 do
if k[i]>0 then Write(c[i],'x',k[i],' ')
end.
Тестовое решение:
Введите значение суммы: 8947
8947 => 500x17 100x4 10x4 5x1 1x2