zoukankan      html  css  js  c++  java
  • Y2K Accounting Bug

    Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc.
    All what they remember is that MS Inc. posted a surplus or a deficit each month of 1999 and each month when MS Inc. posted surplus, the amount of surplus was s and each month when MS Inc. posted deficit, the deficit was d. They do not remember which or how many months posted surplus or deficit. MS Inc., unlike other companies, posts their earnings for each consecutive 5 months during a year. ACM knows that each of these 8 postings reported a deficit but they do not know how much. The chief accountant is almost sure that MS Inc. was about to post surplus for the entire year of 1999. Almost but not quite.

    Write a program, which decides whether MS Inc. suffered a deficit during 1999, or if a surplus for 1999 was possible, what is the maximum amount of surplus that they can post.

    Input

    Input is a sequence of lines, each containing two positive integers s and d.

    Output

    For each line of input, output one line containing either a single integer giving the amount of surplus for the entire year, or output Deficit if it is impossible.

    Sample Input

    59 237
    375 743
    200000 849694
    2500000 8000000
    

    Sample Output

    116
    28
    300612
    Deficit
    
    这个题是说
    有一家公司,每5个月的总营业额必然是亏损的,每组两个数据a,b是每月可能盈利的钱,或者亏损的钱,12个月都一样
    问: 满足每5个月的总营业额必然是亏损的条件,这家公司是赚钱还是亏损,
    赚钱:输出金额;
    亏损:输出Deficit
    分析的话
    12个月可能是以下情况
     
    1 2 3 4 5 6 7 8 9 10 11 12 
    s s s s d s s s s d  s  s //每5个月里只有1个月亏损 
    s s s d d s s s d d  s  s //每5个月里只有2个月亏损 
    s s d d d s s d d d  s  s //每5个月里只有3个月亏损 
    s d d d d s d d d d  s  d //每5个月里只有4个月亏损 
     
    所以  代码是
    #include<stdio.h>
    int main()
    {
        int a,b,t;
        while(~scanf("%d %d",&a,&b))
        {
            if(4*a-b<0) t=10*a-2*b;
            else if(3*a-2*b<0) t=8*a-4*b;
            else if(2*a-3*b<0) t=6*a-6*b;
            else if(a-4*b<0) t=3*a-9*b;
            else t=-1;
            if(t>0) printf("%d
    ",t);
            else printf("Deficit
    ");
        }
        return 0;
    }
  • 相关阅读:
    异常日志以及非异常日志记录方法
    oracle 监测数据库是否存在指定字段
    listview禁止双击一条之后选中复选框按钮的方法
    oracle 的rowid和rownum
    修改文件的名字的写法
    使用C#读取XML节点,修改XML节点
    BZOJ 1004: [HNOI2008]Cards
    P5022 旅行 (NOIP2018)
    P5021 赛道修建 (NOIP2018)
    P5020 货币系统 (NOIP2018)
  • 原文地址:https://www.cnblogs.com/kongkaikai/p/3241811.html
Copyright © 2011-2022 走看看