“Sometimes it is the people no one can imagine anything of who do the things no one can imagine.” ― Sir Alan Turing


ADS

ADS

Tuesday, March 28, 2017

URI 1018 - Banknotes || Solution in C / C++


In this problem you have to read an integer value and calculate the smallest possible number of banknotes in which the value may be decomposed. The possible banknotes are 100, 50, 20, 10, 5, 2 e 1. Print the read value and the list of banknotes.

Input

The input file contains an integer value (0 < < 1000000).

Output

Print the read number and the minimum quantity of each necessary banknotes in Portuguese language, as the given example. Do not forget to print the end of line after each line, otherwise you will receive “Presentation Error”.
Input SampleOutput Sample
576576
5 nota(s) de R$ 100,00
1 nota(s) de R$ 50,00
1 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
1 nota(s) de R$ 5,00
0 nota(s) de R$ 2,00
1 nota(s) de R$ 1,00
1125711257
112 nota(s) de R$ 100,00
1 nota(s) de R$ 50,00
0 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
1 nota(s) de R$ 5,00
1 nota(s) de R$ 2,00
0 nota(s) de R$ 1,00
503503
5 nota(s) de R$ 100,00
0 nota(s) de R$ 50,00
0 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
0 nota(s) de R$ 5,00
1 nota(s) de R$ 2,00
1 nota(s) de R$ 1,00

SOURCE CODE

#include <stdio.h>

int main()

{
  int x, m100, m50, m20, m10, m5, m2;

  scanf("%d", & x);
  printf("%d\n", x);

  printf("%d nota(s) de R$ 100,00\n", x / 100);
  m100 = x % 100;

  printf("%d nota(s) de R$ 50,00\n", m100 / 50);
  m50 = m100 % 50;

  printf("%d nota(s) de R$ 20,00\n", m50 / 20);
  m20 = m50 % 20;

  printf("%d nota(s) de R$ 10,00\n", m20 / 10);
  m10 = m20 % 10;

  printf("%d nota(s) de R$ 5,00\n", m10 / 5);
  m5 = m10 % 5;

  printf("%d nota(s) de R$ 2,00\n", m5 / 2);
  m2 = m5 % 2;

  printf("%d nota(s) de R$ 1,00\n", m2);

  return 0;
}

No comments:

Post a Comment