ACM (TJU) : 2537



/* Question: http://acm.tju.edu.cn/toj/showp2537.html
Author: Tausiq */

#include <stdio.h>

int main ()
{
	int N;
	scanf ("%d", &N);

	int testCase = 0;

	while ( N-- ) {

		int cents;
		scanf ("%d", &cents);

		int quarter = 0;
		int dime = 0;
		int nickel = 0; 
		int pennie = 0;

		while ( cents ) {

			if ( cents >= 25 ) {
				cents -= 25;
				quarter++;
			}

			else if ( cents >= 10 ) {
				cents -= 10;
				dime++;
			}

			else if ( cents >= 5 ) {
				cents -= 5;
				nickel++;
			}

			else if ( cents >= 1 ) {
				cents -= 1;
				pennie++;
			}
		}

		printf ("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)\n", ++testCase, quarter, dime, nickel, pennie);
	}
	return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s