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. [ArcGIS API for JavaScript 4.8] Sample Code-Get Started-layers简介

    [官方文档:https://developers.arcgis.com/javascript/latest/sample-code/intro-layers/index.html] 一.Intro t ...

  2. 解决Maven环境变量配置后,’mvn’不是内部或外部命令的问题

    1. 前往https://maven.apache.org/download.cgi下载的Maven程序,解压放在一个路径下 2.新建环境变量MAVEN_HOME,赋值:解压路径如:  D:\env\ ...

  3. bat 实现主机hostname的修改

    主机实现hostname的修改原理: 修改注册表中的值: hklm\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName 下的 Comp ...

  4. 关于项目中ajax 操作 原生项目遇到的问题

    单选框动态赋值 $('input[name=pszt][value='+val+']').attr("checked",true); 置顶的几种方式 window.scrollTo ...

  5. HNOI2019 苟命记

    Day0 瞎看了看博客,然后看了看wf题,看了一下午柯南剧场版... 后来发现,复习根本没用,因为我根本没学过. Day1 首先随便看了看三道题,觉得 \(T1\) 挺可做的,\(T2\) 看起来是什 ...

  6. 千星项目.Net Core 2.1移植填坑记--OpenAuth.Core诞生

    背景 很早就有把OpenAuth.Net----最好用的.net权限管理工作流框架(好吧!我在吹牛

  7. Linux命令及架构部署大全

    1.Linux系统基础知识 Linux 基础优化配置 Linux系统根目录结构介绍 linux系统重要子目录介绍 Linux基础命令(之一)详解 Linux基础命令(之二)详解 Linux文件系统 L ...

  8. Python写爬虫爬妹子

    最近学完Python,写了几个爬虫练练手,网上的教程有很多,但是有的已经不能爬了,主要是网站经常改,可是爬虫还是有通用的思路的,即下载数据.解析数据.保存数据.下面一一来讲.   1.下载数据 首先打 ...

  9. Spring Cloud微服务系列文,服务调用框架Feign

    之前博文的案例中,我们是通过RestTemplate来调用服务,而Feign框架则在此基础上做了一层封装,比如,可以通过注解等方式来绑定参数,或者以声明的方式来指定请求返回类型是JSON.    这种 ...

  10. C#版 - Leetcode49 - 字母异位词分组 - 题解

    C#版 - Leetcode49 - 字母异位词分组 - 题解 Leetcode49.Group Anagrams 在线提交: https://leetcode.com/problems/group- ...