欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

POJ 2586:Y2K Accounting Bug(貪心)

系統 2532 0

Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 10024
Accepted: 4990

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

      
    

題意是:

      
        對于每個月來說,不是盈利,就是虧損,假設是盈利則盈利S,假設虧空則虧d。
每五個月進行一次統計,共統計八次(1-5月一次,2-6月一次.......8-12月一次)
統計的結果是這八次都是虧空。
問題:推斷全年能否盈利,假設能則求出最大的盈利。
假設不能盈利則輸出Deficit
      
    

      貪心思想:
每五個連續的月一定虧損,也就是不能出現連續5個月盈利,我們能夠設每五個月虧損月數最少為x,這樣的情況下,

假設x能保證讓這五個月為虧損,這是滿足題意的盈利最大值!

(比x大的,盈利也少了,題意是讓求最大利潤),x僅僅能為1,2,3,4,5.

當然x=5時, 則一定虧空。。

除了則之后,也就僅僅有四種情況
      
        ssssd ssssd ss
sssdd sssdd ss
ssddd ssddd ss
sdddd sdddd sd
      

      

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>

using namespace std;

#define M 100500

int main()
{
    int s, d;
    while(~scanf("%d%d", &s, &d))
    {
        if(s>4*d)
        {
            printf("Deficit\n");
            continue;
        }
        int t = 1;
        while(s*(5-t)>d*t)
            t++;
        int k;
        if(t==4)
            k = 2*t+1;
        else
            k = 2*t;
        int ans = s * (12-k) - d*k;
        if(ans>0)
            printf("%d\n", ans);
        else
            printf("Deficit\n");
    }
    return 0;
}

    






POJ 2586:Y2K Accounting Bug(貪心)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: www.日韩 | 中文字幕成人乱码在线电影 | yeyelu| 亚洲精品人人 | 日韩成人免费视频播放 | 亚洲精品一区中文字幕乱码 | 欧美成人午夜在线全部免费 | 日操夜操天天操 | 一区二区三区在线播放 | 在线日韩欧美 | 欧美激情人成日本在线视频 | 欧美影院推理片免费看 | 91精品福利 | 奇米影视在线 | 亚洲高清久久 | 欧美精品一区二区三区在线 | 免费看一级视频 | 色偷偷噜噜噜亚洲男人 | 日韩三级中文 | 亚洲一区二区色情苍井空 | 国产精品一区二 | 日韩av电影在线播放 | 欧美午夜色视频国产精品 | 日韩极品视频 | 黄色免费av | 国内精品免费视频 | 久久国产精品99久久小说 | 久久日本精品99久久久久 | 久久久久久亚洲精品 | 久久精品免费网站 | 久草资源网站 | 午夜av毛片| 久久成人国产 | 久久国产精品超级碰碰热 | 综合二区 | 国产精品不卡 | 欧美大香线蕉线伊人久久 | 成人午夜免费视频毛片 | 色婷婷综合久久久久中文一区二区 | 欧美日韩一区二区三区在线观看 | 8mav福利视频在线播放 |