24h購物| | PChome| 登入
2012-04-19 09:00:41| 人氣937| 回應0 | 上一篇 | 下一篇

[UVA][EASY] 12403 - Save Setu

推薦 0 收藏 0 轉貼0 訂閱站台

A

Save Setu

Rahaduzzaman Setu, (Roll - 12) of 13th batch, CSE, University of Dhaka is tremendously ill. 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.

If anyone wants to contribute now, please send me your contribution or contact me. Please contribute as much as you can to save a life that you saw every week for the first two years of your University life. Please contribute as per your abilities. Our combined effort may save a life.

For more information, consult the link below.

http://supportsetu.com/

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

The first line of input will contain T (1 ≤ T ≤ 100) denoting the number of operations. Then there will be T lines each containing two types of operations as given. You may assume that the input follows the restrictions above.

Output

For each "report" operation, print the total amount of money in the account.

Sample Input

Output for Sample Input

4
donate 1000
report
donate 500
report
1000
1500
 

#include <stdio.h>
#include <string.h>

int main() {
    int t, sum = 0, x;
    char str[20];
    scanf("%d", &t);
    while(t--) {
        scanf("%s", str);
        if(!strcmp(str, "donate")) {
            scanf("%d", &x);
            sum += x;
        } else {
            printf("%d\n", sum);
        }
    }
    return 0;
}

台長: Morris
人氣(937) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][Greedy] 12405 - Scarecrow
此分類上一篇:[UVA] 263 - Number Chains

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文