POJ 3085:quick Change__pku

Source: Internet
Author: User
Quick Change
Time Limit: 1000MS Memory Limit: 65536K
Total submissions: 6111 accepted: 4358

Description

J.P. Flathead ' s grocery Store hires cheap labor to man the checkout stations. The people he hires (usually high school kids) often make mistakes making to the customers. Flathead, who's a bit of a tightwad, figures he loses the more money from this mistakes than he makes; That's, the employees tend to give, the customers than they the should get.

Flathead wants to write a program that calculates the number of quarters ($0.25), dimes ($0.10), nickels ($0.05) and P ENnies ($0.01) that's the customer should get back. Flathead always wants to give the customer's change in coins if the amount due-back are $5.00 or under. He also wants to give the customers back the smallest total number of coins. For example, if it is $1.24, the customer should receive 4 quarters, 2 dimes, 0 nickels, and 4 pennies.

Input

The "a" of input contains an integer N which was the number of datasets that follow. Each dataset consists to a single line containing a single integer which was the change due in cents, C, (1≤ C ≤500).

Output

For each dataset, print out of the dataset number, a space, and the string :

Q quarter (s), D DIME (s), n nickel (s), P PENNY (s)

Where Q is him number of quarters, D is the number of Dimes, N is the number of nickels and P is the number of pennies.

Sample Input

3
124
194

Sample Output

1 4 quarter (s), 2 dime (s), 0 nickel (s), 4 penny (s)
2 1 quarter (s), 0 DIME (s), 0 nickel (s), 0 penny (s)
3 7 Quarter (s), 1 DIME (s), 1 nickel (s), 4 PENNY (s)

Source Greater New York 2006 You left, my world is left with rain ...

#include <stdio.h>
int main ()
{
    int n,c,q,d,x;
    int i;
    scanf ("%d", &n);
    for (i = 1; I <= n; i++)
    {
        q = 0, d = 0, x = 0;
        scanf ("%d", &c);
        Q = C/25;
        c = c%;
        d = C/10;
        c = c%;
        x = C/5;
        c = c% 5;
        printf ("%d%d quarter (s),%d DIME (s),%d nickel (s),%d PENNY (s) \ n", I, Q, D, X, c)
    ;
    return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.