View Code of Problem 4054

#include<iostream>
#include<map>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		map<int, int> money = {
			{100, 0}, {50, 0}, {20, 0}, {10, 0},
			{5, 0}, {1, 0}
		};
		int n;
		cin >> n;
		while (n >= 100) {
			int p = n / 100;
			money[100] += p;
			n = n % 100;

		}
		while (n >= 50) {
			int p = n / 50;
			money[50] += p;
			n = n % 50;
		}
		while (n >= 20) {
			int p = n / 20;
			money[20] += p;
			n = n % 20;
		}
		while (n >= 10) {
			int p = n / 10;
			money[10] += p;
			n = n % 10;
		}
		money[1] += n;
			cout << money[100] << " "<<money[50]<<" "<<money[20]<<" "<<money[10]<<" "<<money[5]<<" "<<money[1]<<endl;
		
	}


}

Double click to view unformatted code.


Back to problem 4054