Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _05.Coins
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal input = decimal.Parse(Console.ReadLine());
- long leva = (long)input;
- long twoLeva = leva / 2;
- long oneLeva = leva % 2;
- decimal coinsCounter = twoLeva + oneLeva;
- decimal cent = (input * 100) % 100;
- while (cent > 0)
- {
- if (cent >= 50)
- {
- cent -= 50;
- coinsCounter++;
- }
- else if (cent < 50 && cent >= 20)
- {
- cent -= 20;
- coinsCounter++;
- }
- else if (cent < 20 && cent >= 10)
- {
- cent -= 10;
- coinsCounter++;
- }
- else if (cent < 10 && cent >= 5)
- {
- cent -= 5;
- coinsCounter++;
- }
- else if (cent < 5 && cent >= 2)
- {
- cent -= 2;
- coinsCounter++;
- }
- else if (cent < 2 && cent >= 1)
- {
- cent -= 10;
- coinsCounter++;
- }
- }
- Console.WriteLine(coinsCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement