Y2K Accounting Bug
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 10117   Accepted: 5043

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

field=source&key=Waterloo+local+2000.01.29">Waterloo local 2000.01.29

这个我确实没怎么弄懂,题意可能没理解

#include<iostream>
using namespace std;
int main()
{
int s,d;
while(scanf("%d %d",&s,&d)!=EOF)
{
int i,ans;
for(i=1;i<=5;i++)
if(s*(5-i)-d*i<0)
break;
if(i==4)
ans=3*s-9*d;
else
ans=s*(12-2*i)-d*2*i;
if(i==5||ans<0)
cout<<"Deficit"<<endl;
else
printf("%d\n",ans);
}
//return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

** poj Y2K Accounting Bug 2586的更多相关文章

  1. Y2K Accounting Bug - 2586

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11271   Accepted: 5672 Description Ac ...

  2. 贪心 POJ 2586 Y2K Accounting Bug

    题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...

  3. Poj 2586 / OpenJudge 2586 Y2K Accounting Bug

    1.Link: http://poj.org/problem?id=2586 2.Content: Y2K Accounting Bug Time Limit: 1000MS   Memory Lim ...

  4. poj 2586 Y2K Accounting Bug

    http://poj.org/problem?id=2586 大意是一个公司在12个月中,或固定盈余s,或固定亏损d. 但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为 ...

  5. poj 2586 Y2K Accounting Bug (贪心)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8678   Accepted: 428 ...

  6. POJ 2586:Y2K Accounting Bug(贪心)

    Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10024 Accepted: 4990 D ...

  7. POJ 2586 Y2K Accounting Bug(枚举洪水问题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

  8. POJ 2586 Y2K Accounting Bug 贪心 难度:2

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10537   Accepted: 52 ...

  9. POJ 2586 Y2K Accounting Bug(枚举大水题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

随机推荐

  1. 基于AdaBoost的人脸检测

    原地址:http://blog.csdn.net/celerychen2009/article/details/8839097 人脸检测和人脸识别都是属于典型的机器学习的方法,但是他们使用的方法却相差 ...

  2. python安装依赖

    yum install zlib zlib-devel openssl openssl-devel bzip2 bzip2-devel ncurses ncurses-devel readline r ...

  3. Extjs4.2 Desktop 拖动黑色和白色的桌面图标的解决方案

    最近做了一个extjs4.2的desktop桌面demo,该desktop从原来的包中剥离出来,并实现了桌面图标休息,拖动桌面图标,但是,用户抱怨拖动桌面图标会出现黑色和白色,测试,在 extjs4. ...

  4. php设计模式——UML类图

    前言 用php开发两年多了,准备也写一下平时常用的设计模式,都是基于自己的实践经验,当然,用设计模式之前首先要看懂设计模式,因此这里首先讲解一下UML类图.通过UML类图,能更好的和大家交流,也能很容 ...

  5. android视频库Vitamio

    之前尝试自己解码视频,然后播放显示,虽然音视频都可以播放,但是实现不了音视频的同步,所以使用第三方的视频库Vitamio来实现视频播放器功能,这样自己只需要实现播放解码的制作不不要关心底层解码和显示问 ...

  6. hdu2389(HK算法)

    传送门:Rain on your Parade 题意:t个单位时间后开始下雨,给你N个访客的位置(一维坐标平面内)和他的移动速度,再给M个雨伞的位置,问在下雨前最多有多少人能够拿到雨伞(两个人不共用一 ...

  7. 如何解决This system is not registered with RHN.

    今天我必须写下这篇文章,由于在我刚刚接触到Linux下安装oracle时碰到了Linux中少xscreensaver.rpm包自己弄了非常久.最后还是被一个大哥帮我攻克了:仅仅能说非常的感谢你! 我试 ...

  8. 事务的使用示例及WinForm实现中的若干问题

    --事务的使用示例 create database MyDB go use MyDB create table account ( Id int identity primary key, balan ...

  9. hdu4578(线段树)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 题意:n个数,初始值为0,4种操作: 1.将某个区间所有值加上另一个值: 2.将区间所有值都乘上 ...

  10. 压缩js参数保存解决方法

    angular.js  中 找到 if (typeof fn === 'function') 在 if (fn.length) { console.warn("此函数没有注入注解,将导致编译 ...