• 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;
    }
  • 相关阅读:
    小米路由研究之中的一个加入菜单
    【Struts2学习笔记(9)】单文件上传和多文件上传
    isPostback 的原理及作用(很easy)
    1-2Html与CSS的关系
    【HTML5】实现QQ聊天气泡效果
    杭电1166敌兵布阵 (用的树状数组)
    安卓市场---框架搭建4
    qcow2 raw vhd 虚拟磁盘转换
    softlayer virtual machine vhd磁盘镜像导入shell脚本
    Openstack no valid hot
  • 原文地址:https://www.cnblogs.com/kongkaikai/p/3241811.html
Copyright © 2020-2023  润新知