URI ONLINE JUDGE SOLUTION 1018 - Banknotes

Problem

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 N (0 < N < 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”.

sample input output


Solution

#include<stdio.h>
int main()
{
    int x,i,n[]={100,50,20,10,5,2,1},y[7];
    scanf("%d",&x);
    printf("%d\n",x);
    for(i=0;i<7;i++){
        y[i]=x/n[i];
        x=x%n[i];
        printf("%d nota(s) de R$ %d,00\n",y[i],n[i]);
    }
  return 0;

}

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula