Quick Change
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6288   Accepted: 4468

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 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.

Input

The first line of input contains an integer 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).

Output

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.

Sample Input

3
124
25
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

 
是一道水题8~
 
 #include <iostream>
#include <cstdio>
using namespace std; int main()
{
int N;
int t;
int cha;
scanf("%d",&N);
t=;
while(t<=N){
int q=;
int d=;
int n=;
int p=;
scanf("%d",&cha);
while(cha->=){
cha=cha-;
q++;
}
while(cha->=){
cha=cha-;
d++;
}
while(cha->=){
cha=cha-;
n++;
}
while(cha->=){
cha=cha-;
p++;
}
printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)\n",t,q,d,n,p);
t++;
}
return ;
}

错倒不是错,但是都减那么多次了,为什么就那么笨想不到除呢。

改进:

#include <iostream>
#include <cstdio>
using namespace std; int main()
{
int N;
int t;
int cha;
scanf("%d",&N);
t=;
while(t<=N){
scanf("%d",&cha);
int q,d,n,p;
q=cha/;
cha%=;
d=cha/;
cha%=;
n=cha/;
cha%=;
p=cha;
printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)\n",t,q,d,n,p);
t++;
}
return ;
}

POJ 3085 - Quick Change的更多相关文章

  1. zoj 2772 Quick Change

    Quick Change Time Limit: 2 Seconds      Memory Limit: 65536 KB J.P. Flathead's Grocery Store hires c ...

  2. POJ Charlie's Change 查理之转换(多重背包,变形)

    题意: 给定身上的4种硬币,分别是1 ,5 ,10, 25面额各有多张,要求组成面额p的硬币尽可能多.输出组成p的4种硬币各自的数量. 思路: 多重背包,300+ms.用01背包+二进制的方法.记录下 ...

  3. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  4. Making the Elephant Dance: Strategic Enterprise Analysis

    http://www.modernanalyst.com/Resources/Articles/tabid/115/ID/2934/categoryId/23/Making-the-Elephant- ...

  5. macbook pro install ubuntu

    https://help.ubuntu.com/community/MacBookPro Determine your hardware revision To determine which ver ...

  6. UVALive 7352 Dance Recital

    题意: 有n种舞蹈要跳 每种舞蹈需要每一行字符串所对应的那些人 如果一个人连着跳两个舞蹈 那么需要一个quick change 问需要的最少quick changes是多少 思路: 假期的题 又拿出来 ...

  7. Making every developer more productive with Visual Studio 2019

    Today, in the Microsoft Connect(); 2018 keynote, Scott Guthrie announced the availability of Visual ...

  8. ACM Dance Recital(dfs+剪枝)

    The Production Manager of a dance company has been tasked with determining the cost for the seasonal ...

  9. How To Install Apache Tomcat 7 on CentOS 7 via Yum

    摘自:https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-centos-7-via-y ...

随机推荐

  1. C#获取页面上的Html

    //根据Url地址得到网页的html源码 public static string GetWebContent(string Url) { string strResult = "" ...

  2. box-shadow内阴影、外阴影

    外阴影: box-shadow:X轴  Y轴  Rpx  color; 属性说明(顺序依次对应):阴影的X轴(可以使用负值) 阴影的Y轴(可以使用负值) 阴影模糊值(大小) 阴影的颜色 内阴影: bo ...

  3. 关于openssl的交叉编译

    最近有个项目用到openssl,于是去openssl的官方网站上下载了最新的版本,v1.1.1b版本. 解压之后,发现配置编译,可以使用./config或者./Configure来完成. 网上也查了一 ...

  4. Windows Server 2016-DNS客户端新增功能

    域名系统(DNS)是包含TCP / IP的行业标准协议套件之一,DNS客户端和DNS服务器一起为计算机和用户提供计算机名称到IP地址映射名称解析服务. 在Windows Server 2016中,DN ...

  5. MongoDB 4.0 开发环境搭建集群

    环境准备 Liunx 服务器一台 以下示例为单机版安装集群, 没有分片 MongoDB 安装 1.下载 MongoDB tgz 安装包: 可以从下载中心下载: https://www.mongodb. ...

  6. Python项目,VS Code控制台输出乱码问题解决办法

    一.添加系统变量 在window环境变量中,添加环境变量 PYTHONIOENCODING = UTF-8. 二.在文件中设置输出编码 import io import sys sys.stdout ...

  7. 新更新kb4493472导致无法正常开机

    昨天陆续接到电话,说是系统更新后电脑不能正常使用,症状基本是开机到欢迎界面就出现各种各样的状况,比如鼠标能动,其他无反应;欢迎界面结束后黑屏,只有鼠标能动:开机后正常,但电脑使用很卡等等状况.因为昨天 ...

  8. redis 初识

    架构 sharding redis 集群是主从式架构,数据分片是根据hash slot(哈希槽来分布) 总共有16384个哈希槽,所以理论上来说,集群的最大节点(master) 数量是16384个.一 ...

  9. linux 下搭建php环境

    linux 下搭建php环境 1.下载apache (http://httpd.apache.org/download.cgi) 下载php组件 ( http://cn2.php.net/get/ph ...

  10. Mongodb在CSharp里实现Aggregate

    回到目录 今天主要用了一个mongodb.driver里的分组,事实上在网上介绍这方面的文章非常少,以至于我在出现问题后,无法找到一个正确的解决方案,最后还是通过异常信息找到的解决方法,所以感觉自己更 ...