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. solr的认识、linux下安装、java下使用(含下载资源)

    目录 一.solr的大概认识 二.solr安装 三.solr的深度认识 四.solr的使用 (1)由于我们用到中文,所以需要中文分析器,这里我用IK Analyzer 2012FF_hf1 (2)同时 ...

  2. 18 章 CSS 链接、光标、 DHTML 、缩放

    1.CSS 中链接的使用 2.CSS 中光标的使用 3.CSS 中 DHTML 的使用 4.CSS 中缩放的使用 1 18 8. .1 1 S CSS  中 链接的使用 超链接伪类属性 a:link ...

  3. DataPipeline丨金融行业如何统一管理单个任务下所有API的同步情况

    目前,依靠"手工人力"的电子表格数据治理模式逐渐被"自动智能"的专业工具取代.数据管理员.业务分析师开始采用"平台工具"来梳理主数据.元数据 ...

  4. 安卓开发笔记(二十五):ViewPager的使用

    首先我们来看看运行之后的效果: 然后我们也不多说废话了,下面是这个项目所需要的全部代码,很多博主写这个都不把代码写完,因此笔者自己也琢磨了一会儿才把这个弄出来,感觉很烦,但我肯定会把代码写全的.我这里 ...

  5. bat脚本自定义魔兽warIII运行分辨率,去黑边

    我们一般平时安装完WarIII后运行时的分辨率默认是800*600,导致有黑边的存在.所以我写了一个bat脚本来自定义WarIII的运行分辨率.需要以管理员身份运行. 下载链接: 链接:https:/ ...

  6. 微信小程序小结

    前几日抽空看了下小程序,发现挺好玩的,mvvm的结构,语法比vue要简单,内置了一系列的组件,很方便.然后开发者工具直接上传代码,提交审核,然后发布,感觉挺好.虽然不打算做个工具类的,但是做个介绍类小 ...

  7. 最短路问题之Dijkstra算法

    题目: 在上一篇博客的基础上,这是另一种方法求最短路径的问题. Dijkstra(迪杰斯特拉)算法:找到最短距离已经确定的点,从它出发更新相邻顶点的最短距离.此后不再关心前面已经确定的“最短距离已经确 ...

  8. #Java学习之路——基础阶段二(第六篇)

    我的学习阶段是跟着CZBK黑马的双源课程,学习目标以及博客是为了审查自己的学习情况,毕竟看一遍,敲一遍,和自己归纳总结一遍有着很大的区别,在此期间我会参杂Java疯狂讲义(第四版)里面的内容. 前言: ...

  9. 爬虫框架之Scrapy(四 ImagePipeline)

    ImagePipeline 使用scrapy框架我们除了要下载文本,还有可能需要下载图片,scrapy提供了ImagePipeline来进行图片的下载. ImagePipeline还支持以下特别的功能 ...

  10. IDEA同步上传lua代码,方便开发。

    因项目是Java和lua一起开发的,以前用Notepad++插件连接,每次关掉得重新寻找目录.有点耗时间,所以用idea提供的工具很是便利,再此做个笔记. 点击上面的绿色”+“号,添加 在配置mapp ...