LightOJ - 1387 Setu (模拟)水
来源:互联网 发布:日本转区软件 编辑:程序博客网 时间:2024/05/01 04:34
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 addK 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 beN 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
#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;}
- LightOJ - 1387 Setu (模拟)水
- Light 1387-Setu
- Light oj 1387 - Setu【字符串】
- LightOJ - 1016 Brush (II) (模拟)水
- LightOJ - 1042 Secret Origins (模拟)水
- LightOJ - 1389 Scarecrow (水模拟)
- LightOJ - 1241 Pinocchio (模拟)
- LightOJ - 1249 Chocolate Thief (模拟)
- LightOJ - 1261 K-SAT Problem (模拟)
- Lightoj--1338--Hidden Secret!(模拟)
- Lightoj 1078(模拟取余)
- Setu(水题)
- LightOJ 1389 - Scarecrow【模拟】
- LightOJ 1241- Pinocchio【模拟】
- LightOJ 1005 - Rooks (组合数学dp模拟)
- lightoj 1148 - Mad Counting (数学规律&模拟)
- LightOJ 1197 - Help Hanzo (模拟筛素法区间筛素)
- LightOJ - 1374 Confusion in the Problemset (模拟)
- jps -- java 进程查看命令
- Sudoku Solver
- IOS学习 导入第三方框架 常见问题汇总
- hadoop正式学习之redis---redis的主从复制与Sentinel以及集群搭建
- 基于JBox2D物理引擎开发的“雷电”小游戏(二)——创建世界
- LightOJ - 1387 Setu (模拟)水
- Linux Mint (应用软件:QT 5.X)
- java 基础数据类型与循环结构要点
- 数据包嗅探 Packet Sniffing
- 关于<T extends Comparable<? super T>>的理解
- 1042. 字符统计(20)
- HDU-4499 Cannon (DFS)
- uva 274 Calling Circles
- 调整单链表使得奇数位置的元素位于偶数位置元素之前