zoukankan      html  css  js  c++  java
  • POJ 2856 Y2K Accounting Bug【简单暴力】

    链接:



    Y2K Accounting Bug
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 8472   Accepted: 4185

    Description

    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
    

    Source


    题目:

    题意很坑,题目很水,我等弱菜+英语白痴怎么受得了抓狂
    有个公司丢失了一些数据,他们的数据【盈利s,亏损d】都是每5个月报一次,所以一年当然是报 8 次了咯。
    现在给你一组 s 和 d 。要你求出全年最大可能的盈利值,如果不肯能盈利则输出 Deficit

    思路:

    给你的数据有盈利 S 和亏损 D
    那么上报一次数据的 5 个月,只可能有 5 种情况:
    盈利四个月,亏损一个月:ssssd -> ssssdssssdss 【保证了对应每次报数据都是盈利四个月,亏损一月,下面同】
    盈利三个月,亏损二个月:sssdd -> sssddsssddss
    盈利二个月,亏损三个月:ssddd -> ssdddssdddss
    盈利一个月,亏损四个月:sdddd -> sddddsddddsd
    连续亏损 5 个月必定亏损= =
    记得去年看过MMchen的博客Orz

    code:

    #include<stdio.h>
    int main()
    {
        int s, d;
        while(scanf("%d%d", &s,&d) != EOF)
        {
            int ans = -1;
            if(4*s < d) ans = 10*s-2*d; //ssssd
            else if(3*s < 2*d) ans = 8*s-4*d; //sssdd
            else if(2*s < 3*d) ans = 6*s-6*d; //ssddd
            else if(s < 4*d) ans = 3*s-9*d; //sdddd
            if(ans < 0) printf("Deficit
    ");
            else printf("%d
    ", ans);
            //for(int i = 1; i <= 12; i++) printf("%d
    ", i*s-(12-i)*d);
        }
    
        return 0;
    }


  • 相关阅读:
    KVO的用法、底层实现原理
    Runtime应用(三)实现NSCoding的自动归档和自动解档
    Runtime应用(二)使用对象关联为分类增加属性(每个对象的属性互不干扰)
    Runtime 应用(一)拦截系统自带的方法交换实现
    iOS实现传递不定长的多个参数
    Runtime 中的 _cmd、 IMP
    UIWebView、WKWebView使用详解及性能分析
    iOS
    基本图形生成算法
    关于动画中帧的解释
  • 原文地址:https://www.cnblogs.com/freezhan/p/3238986.html
Copyright © 2011-2022 走看看