Quick Change hdu
来源:互联网 发布:淘宝上下架规则 编辑:程序博客网 时间:2024/06/05 07:10
Quick Change
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 8 Accepted Submission(s) : 6
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 change for the customers. Flathead, who’s a bit of a tightwad, figures he loses more money from these mistakes than he makes; that is, the employees tend to give more change to the customers than they should get.
Flathead wants you to write a program that calculates the number of quarters ($0.25), dimes ($0.10), nickels ($0.05) and pennies ($0.01) that the customer should get back. Flathead always wants to give the customer’s change in coins if the amount due back is $5.00 or under. He also wants to give the customers back the smallest total number of coins. For example, if the change due back is $1.24, the customer should receive 4 quarters, 2 dimes, 0 nickels, and 4 pennies.
The first line of input contains an integer N which is the number of datasets that follow. Each dataset consists of a single line containing a single integer which is the change due in cents, C, (1 ≤ C ≤ 500).
For each dataset, print out the dataset number, a space, and the string:
Q QUARTER(S),
D DIME(S),
n NICKEL(S),
P PENNY(S)
Where Q is he number of quarters, D is the number of dimes, n is the number of nickels and P is the number of pennies.
312425194
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)
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int c,n,i,j,k; int a[4]; scanf("%d",&n);//25 ,10 ,5, 1 for(i=1;i<=n;i++) { memset(a,0,sizeof(a)); scanf("%d",&c); a[0]=c/25; c=c-a[0]*25; a[1]=c/10; c=c-a[1]*10; a[2]=c/5; c=c-a[2]*5; a[3]=c; printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)\n",i,a[0],a[1],a[2],a[3]); } return 0;}
- HDU Quick Change
- Quick Change hdu
- hdu ——Quick Change
- zoj 2772 Quick Change
- HOJ 2411 Quick Change
- poj 3085 Quick Change
- POJ 3085:Quick Change
- zju2772快速找零Quick Change
- POJ 3085 Quick Change (贪心)
- POJ 3085 Quick Change G++
- Change HDU
- zoj 2772 Quick Change(水~)
- ZOJ Problem Set - 2772 Quick Change
- HDU 2069 Coin Change
- HDU 2068 Coin Change
- HDU 4357 String change
- HDU 4357 - String change
- hdu---String change
- -------
- SQL Server 2008阻止保存要求重新创建表的更改的解决
- 查找峰值点,求相关
- hdu 4578——Transformation
- (Ext基础篇) 表单与输入控件
- Quick Change hdu
- 在Xlib中,从XImage中取出R,G,B三分量
- Gray Code
- EF更新数据库报错:初始化数据库时发生异常。有关详细信息
- 【热门主题】紫色梦幻天使win7主题
- 【xinfanqie】电脑必须避免的11个注意事项
- dom4j解析和修改xml
- 数论题大集合
- maven安装jar到本地库要注意的问题