EOJ2968. 付钱

单点时限: 2.0 sec

内存限制: 256 MB

李奶奶年纪大了算术不太好了,每次买东西想不清要怎么付钱,请你写一个程序帮助李奶奶。对于每一个金额(以元为单位的整数,如 412 元), 显示支付这个金额的各种面额人民币的数量,要求从最大面额的人民币给起,直到最小面额的人民币,即 100 元、50 元、20 元、10 元、5 元、1 元各多少数量。

输入格式

第 1 行:整数 T (1≤T≤10) 为问题数

第 2 ∽ T+1 行:每一个问题中的金额 n (0⩽n⩽10000)。

输出格式

对于每个问题,输出一行问题的编号(0 开始编号,格式:case #0: 等),然后在一行中输出 100 元、50 元、20 元、10 元、5 元、1 元各多少数量,用空格分隔,最后一个数没有空格。

样例

input

4
0
68
78
10

output

case #0:
0 0 0 0 0 0
case #1:
0 1 0 1 1 3
case #2:
0 1 1 0 1 3
case #3:
0 0 0 1 0 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int jobs, temp;
    vector<int> moneys;
    // 输入
    cin >> jobs;
	for(int i=0;i<jobs;i++){
		cin >> temp;
		moneys.insert(moneys.end(), temp);
	}
	// 格式化与输出
	int money, nums[6];
	int values[6] = {100,50,20,10,5,1};
	for(int i=0;i<jobs;i++){
		money = moneys[i];
		if(money == 0){
			cout <<"case #"<<i<<":\n"<<"0 0 0 0 0 0"<<endl;
		}
		while(money > 0)
		{
			cout <<"case #"<<i<<":" <<endl;
			for(int j=0;j<6;j++){
				nums[j] = money/values[j];
				money = money % values[j]; 
				printf("%d", nums[j]);	
				if(j==5) break;
				printf(" ");			
			}
			if(i == jobs-1)	break;
			cout << endl;
		}
	}	
    return 0;
} 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值