Condition Tasks :
Clean CDs sell in three types of packages. Packaging of 100 disks costs 100 UAH., Out of 20 disks – 30 UAH., And one disk costs 2 UAH. What minimum amount need to be spent to buy n such disks?
It seems to be solved, the tests are executed correctly, but E-Olymp does not count on 100%. What is the problem?
# include & lt; stdio.h & gt;
INT MAIN (Void) {
int n;
Scanf ("% d", & amp; n);
PrintF ("% d", (n / 100 * 100) + (n% 100/20 * 30) + (N% 100% 20 * 2));
Return 0;
}
Answer 1, Authority 100%
You do not consider that, for example, buy 19 disks – cheaper than a pack for 30 hryvnias than one disk 2 hryvnia …
Simple and freaky – just compare options …
int main (int argc, char * argv [])
{
int n;
CIN & GT; & GT; n;
INT D100 = N / 100, D20 = N% 100/20, D1 = N% 20;
int s = d100 * 100 + d20 * 30 + d1 * 2;
int m = d100 * 100 + (d20 + 1) * 30;
int k = (D100 + 1) * 100;
if (s & gt; m) s = m;
if (S & gt; k) s = k;
COUT & LT; & LT; s;
}