zoukankan      html  css  js  c++  java
  • Setu(水题)

    K - Setu
    Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

    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

    纯粹为了刷CSDN的积分。。。

    //Memory: 904 KB		Time: 40 MS
    //Language: C		Result: Accepted
    
    #include <stdio.h>
    
    int main()
    {
        int ans, T, N, m;
        char s[7];
        scanf("%d", &T);
        for(int ca=1; T--; ca++)
        {
            ans=0;
            scanf("%d", &N);
            printf("Case %d:\n", ca);
            while(N--)
            {
                scanf("%s", s);
                if(s[0] == 'd')
                {
                    scanf("%d", &m);
                    ans += m;
                }
                else
                    printf("%d\n", ans);
            }
        }
        return 0;
    }


  • 相关阅读:
    越来越火的5G公网专用,到底是啥意思?
    看懂IPv6+,这篇就够了
    今年诺贝尔奖得主居然把这事研究清楚了:学历和收入到底有多大关系?
    华为发布《智能世界2030》报告,多维探索未来十年趋势
    每天一个离职小技巧
    Deepsort + Yolo 实现行人检测和轨迹追踪
    “5G+AI”到底有啥用?这篇漫画告诉你答案…
    全国多地拉闸限电 背后到底怎么了?
    【Ajax请求 】- 1.1前端和后台数据交互的说明
    【Web API系列教程】3.3 — 实战:处理数据(建立数据库)
  • 原文地址:https://www.cnblogs.com/cszlg/p/2910580.html
Copyright © 2011-2022 走看看