zoj 2772 Quick Change
Quick Change
Time Limit: 2 Seconds Memory Limit: 65536 KB
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 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).
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)
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int c;
int q, d, n, p, m;
cin >> c;
for(int i = ; i <= c; i++){
cin >> m;
q = m / ;
m = m % ;
d = m / ;
m = m % ;
n = m / ;
p = m % ;
printf("%d %d QUARTER(S), %d DIME(S), %d NICKEL(S), %d PENNY(S)\n", i, q, d, n, p);
}
return ;
}
最新文章
- FPGA Timing笔记
- 解决警告“ld: warning: directory not found for option
- [Java] Java解析XML格式Response后组装成Map
- 如何居中一个div?
- 体验一下cygwin
- Spring @Service生成bean名称的规则
- 完美实现自己的GetProcAddress函数(转载)
- ODAC连接远程Oracle数据库时,数据源名称orcl改为gscloud
- JDBC入门连接MySQL查数据
- Android中Action
- 一次不是事故的SSH闪断问题
- 【第七篇】Volley之处理Gzip数据
- bg-render+bg-class+filter
- git报错:&#39;fatal:remote origin already exists&#39;怎么处理?附上git常用操作以及说明。
- idea上maven使用心得(三)——用pom.xml添加jar包
- 16路PWM输出的pca9685模块
- Swift 与 C 语言混合编程
- atime,mtime,ctime 的理解
- MySql5.5安装(windows)
- OG数据预处理
热门文章
- matplotlib 绘图实例01:正弦余弦曲线
- 使用VMwaver 克隆CentOS 6.9网卡配置报错
- apt-get的一些坑
- re正则表达式讲解—初步认识
- poj2385 Apple Catching
- mac上的应用提权
- PMP项目管理学习笔记(5)——整合管理之制定项目章程
- SQL Server之增删改操作
- (转)Spring4.2.5+Hibernate4.3.11+Struts1.3.8集成方案一
- Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest(二月十日训练赛)