题目:

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,公司每连续5个月进行一次统计,结果都是亏损,问公司是否能盈利?能就输出盈利,否就输出Deficit。
*/
那么总共就只有5种情况:
   1.每次有1个月亏损,即0<4s<d→0<s<d/4,为SSSSDSSSSDSS;
   2.每次有2个月亏损,即3s<2d→s<2d/3,为SSSDDSSSDDSS;
   3.每次有3个月亏损,即2s<3d→s<3d/2,为SSDDDSSDDDSS;
   4.每次有4个月亏损,即s<4d,为SDDDDSDDDDSD;
   5.每次有5个月亏损,即s>=4d,为DDDDDDDDDDDD;
 
代码如下:
 #include<iostream>
using namespace std;
int main()
{
double s,d;
while(cin>>s>>d)
{
double n;
if(s>= && s<d/) n=*s-*d;
if(s>=d/ && s<*d/) n=*s-*d;
if(s>=*d/ && s<*d/) n=*s-*d;
if(s>=*d/ && s<*d) n=*s-*d;
if(s< || (s== && d>=) || s>=*d) n=-;
if(n>=) cout<<n<<endl;
else cout<<"Deficit\n";
}
return ;
}

Y2K Accounting Bug的更多相关文章

  1. [POJ2586]Y2K Accounting Bug

    [POJ2586]Y2K Accounting Bug 试题描述 Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...

  2. Y2K Accounting Bug(贪心)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10945   Accepted: 54 ...

  3. 贪心 POJ 2586 Y2K Accounting Bug

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

  4. Y2K Accounting Bug 分类: POJ 2015-06-16 16:55 14人阅读 评论(0) 收藏

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11222   Accepted: 56 ...

  5. 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 ...

  6. POJ2586——Y2K Accounting Bug

    Y2K Accounting Bug   Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...

  7. poj 2586 Y2K Accounting Bug

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

  8. poj2586 Y2K Accounting Bug(贪心)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=2586 ------ ...

  9. poj 2586 Y2K Accounting Bug (贪心)

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

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

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

随机推荐

  1. MySQL在远程访问时非常慢的解决skip-name-resolve 并且出现 Reading from net

    转载:http://www.itokit.com/2012/0515/73932.html 服务器放在局域网内进行测试时,数据库的访问速度还是很快.但当服务器放到外网后,数据库的访问速度就变得非常慢. ...

  2. vi或vim快捷键

    1.dG:这是删除光标所在行到最后一行的内容(包括光标所在行的内容) 2.ggVG全选

  3. TDirectory.GetAttributes、TDirectory.SetAttributes获取和设置文件夹属性

    使用函数: System.IOUtils.TDirectory.GetAttributes//获取属性 System.IOUtils.TDirectory.SetAttributes//设置属性 注: ...

  4. lua在MacOS系统上的安装方法

    lua是一种非常小巧的脚本语言,由标准C编写而成,可以很方便的调用c/c++或者被c/c++.另外相关的还有一个luaJIT,是lua在某些平台上的编译器. 我们在这里只安装lua. 1.检测电脑上是 ...

  5. JavaScript模块化开发实例

    最近接触了一些JavaScript开发的例子,在这里与大家一起分享一下: 例子:当我们一个团队在写Js文件的时候,你一个人写的JS代码自己可以看懂也可以维护,但是别人想对你的JS进行扩展的话,如果都在 ...

  6. json序列化后日期如何变回来

    日期格式为 日期小于10的时候 占一位 比如 2019年9月1日 2015/9/1 function ChangeDateFormat(cellval) {           var date = ...

  7. wpf+xml实现的一个随机生成早晚餐的小demo

    话说每到吃完的时间就发愁,真的不知道该吃什么,然后就想到做一个生成吃什么的小软件,既然这个软件如此的简单,就打算用wpf开发吧,也不用数据库了,直接保存在xml中就可以了 程序整体结构如下图 首先我写 ...

  8. Dom学习笔记-(一)

    一.概述 DOM(文档对象模型)是针对HTML和XML文档的一个API,其脱胎于DHTML. DOM可以将任意HTML和XML文档描绘成一个由多层节点构成的结构. 每一个文档包含一个根节点-文档节点, ...

  9. [Codeforces Round #254 div1] C.DZY Loves Colors 【线段树】

    题目链接:CF Round #254 div1 C 题目分析 这道题目是要实现区间赋值的操作,同时还要根据区间中原先的值修改区间上的属性权值. 如果直接使用普通的线段树区间赋值的方法,当一个节点表示的 ...

  10. 听同事讲 Bayesian statistics: Part 2 - Bayesian inference

    听同事讲 Bayesian statistics: Part 2 - Bayesian inference 摘要:每天坐地铁上班是一件很辛苦的事,需要早起不说,如果早上开会又赶上地铁晚点,更是让人火烧 ...