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. 交给子类: Template Method(模板方法模式)【PHP】

    Template Method(模板方法模式) ---- 将具体处理交给子类 Template Method 就是定义一个操作中的算法骨架,而将一些步骤延迟到子类中,使得子类可以不改变一个算法的结构可 ...

  2. 【工作查漏补缺】jQuery ajax - serializeArray()

    方法用途: 获取表单内的所有有name的所有数据框,在非表单提交需要挨个遍历组装数据的情况下很好用 ps:需要jQuery支持 var twoform = $("#editProductAc ...

  3. SharePoint布局页创建(实战)

    分享人:广州华软 极简 一. 前言 SharePoint有母版页及布局页,母版页控制页面头部.底部,而布局页则控制页面中间内容区域.通过布局页,可以快速修改页面内容区域. SharePoint的页面布 ...

  4. 数据库原理 - 序列3 - 事务是如何实现的? - Redo Log解析

    6.5 事务实现原理之1:Redo Log 介绍事务怎么用后,下面探讨事务的实现原理.事务有ACID四个核心属性:A:原子性.事务要么不执行,要么完全执行.如果执行到一半,宕机重启,已执行的一半要回滚 ...

  5. spring 【二】学习之spring EL

    spring EL-spring 表达式语言,支持在xml和注解的形式,类似于JSP的el表达式的形式. 其主要使用@Value注解的结构形式 其主要功能 [1].注入普通字符串 [2].注入操作系统 ...

  6. 利用requirejs实现vue的模块化开发

    通常vue都是搭配webpack+vue-cli使用的 如果不在nodejs环境下开发web应用呢? 这里提出一个解决方案: 1.加载requirejs,并且指定main函数 <script d ...

  7. iOS可视化动态绘制连通图(Swift版)

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  8. Nginx 相关介绍

    Nginx的产生 没有听过Nginx?那么一定听过它的"同行"Apache吧!Nginx同Apache一样都是一种WEB服务器.基于REST架构风格,以统一资源描述符(Unifor ...

  9. 一篇读懂HTTPS:加密原理、安全逻辑、数字证书等

    1.引言 HTTPS(全称: Hypertext Transfer Protocol Secure,超文本传输安全协议),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.本文,就来深入介绍下其 ...

  10. Linux下安装vmtools的语句

    sudo apt-get upgrade sudo apt-get install open-vm-tools-desktop -y sudo reboot 出现提示信息不确定就默认就好,一路y或ye ...