LightOJ - 1387 Setu (模拟)水

LightOJ - 1387
Time Limit:                                                        2000MS                       Memory Limit: 32768KB64bit IO Format:                            %lld & %llu                       

SubmitStatus

Description

Rahaduzzaman Setu, (Roll - 12) of 13th batch, CSE, University of Dhaka. He passed away on 18th April 2012. This is one of the saddest news to all. May he rest in peace. This problem is dedicated to him.

This problem was written during his treatment. He will be in our prayers, always.

"He has been suffering from Multi Drug Resistant TB for a long time. Now, his left lung is damaged and beyond repair. No medicine is working on his body to ease his pain. It is urgent to operate on his left lung so that the disease doesn't spread to his right lung. It can either be removed through surgery or transplanted. He comes from a modest family and it is difficult and impossible for them to bare his medical expenses anymore. Because of the money needed (12 million BDT) to transplant, it is his family's decision to go with the surgery (3 million BDT). We must help them financially by raising money. But we must not be confined with that amount only to do the surgery. We must go for the Transplant. Our target will be to collect as much as possible to help our friend [link]."

However, in this problem, you have to build a software that can calculate the donations. Initially the total amount of money is 0 and in each time, two types of operations will be there.

1)      "donate K" (100 ≤ K ≤ 105), then you have to add K to the account.

2)      "report", report all the money currently in the account.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer N (1 ≤ N ≤ 100) denoting the number of operations. Then there will be N lines each containing two types of operations as given. You may assume that the input follows the restrictions above. Initially the account is empty for each case.

Output

For each case, print the case number in a single line. Then for each "report" operation, print the total amount of money in the account in a single line.

Sample Input

2

4

donate 1000

report

donate 500

report

2

donate 10000

report

Sample Output

Case 1:

1000

1500

Case 2:

10000

Hint

Source

Problem Setter: Jane Alam Jan
Special Thanks: Sohel Hafiz
//题意:
有一个募捐箱,若遇到“donate n”就表示往募捐箱里放n元,遇到“report”表示一个询问,即此时箱子中有多少钱。
#include<cstdio>
#include<set>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int t,k=1;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		printf("Case %d:\n",k++);
		char s[20];
		int sum=0;
		for(int i=0;i<n;i++)
		{
			int x;
			scanf("%s",s);
			if(s[0]=='d'){
				scanf("%d", &x);
				sum+=x;
			}
			else if(s[0]=='r'){
				printf("%d\n",sum);
			}
			
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值