题目:

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. asp.net中生成缩略图并添加版权实例代码

    这篇文章介绍了asp.net中生成缩略图并添加版权实例代码,有需要的朋友可以参考一下 复制代码代码如下: //定义image类的对象 Drawing.Image image,newimage; //图 ...

  2. C++库编译

    C++库编译 1. POCO编译 进入源文件目录,选择相应的VS版本进行编译(build_vs140).    设置系统环境变量: POCO_BASE 2. Boost编译 ####简单编译    在 ...

  3. 如何处理ajax中嵌套一个ajax

    在做项目的时候 遇到过第二次了 当我第二次去问'公子'的时候 被吐槽了 原来我以前遇到过 只是忘记了...他老人家竟然还记得... ajax由于他的异步特性 在第一次请求中的循环中嵌套第二个ajax会 ...

  4. 理解Python的迭代器

    首先,廖雪峰老师的教程中解释了迭代器和生成器,这篇文章只是补充和我个人的总结. 什么是迭代 可以直接作用于for循环的对象统称为可迭代对象(Iterable). 可以被next()函数调用并不断返回下 ...

  5. java中关于移位运算符的demo与总结

    首先,移位运算符有三种,其操作类型只支持:byte / short / char / int和long五种. << 左移运算符,表示将左边的操作数的二进制数据向左移动*位,移动后空缺位以0 ...

  6. 转:Redis Geo: Redis新增位置查询功能

    原文来自于:http://www.infoq.com/cn/news/2015/07/redis-geo 移动互联网增进了人与人之间的联系,其中基于位置信息的服务(Location Based Ser ...

  7. CENTOS6上禁用IPV6和DHCP

    centos 6禁用ipv6方法   首先,在终端输入 ip -6 addr show 和 lsmod | grep ipv6查询一下有无安装IPV6模块,或用netstat -nuptl查看是否有i ...

  8. Linq 取差集 交集等

    string goodsList = context.Request.Form["goodsList"]; if (!string.IsNullOrEmpty(goodsList) ...

  9. 【POJ 3167】Cow Patterns (KMP+树状数组)

    Cow Patterns Description A particular subgroup of K (1 <= K <= 25,000) of Farmer John's cows l ...

  10. ANDROID_MARS学习笔记_S05_004_过滤杂质,得到真正的加速度

    一.简介 二.代码1.java (1)MainActivity.java import android.app.Activity; import android.content.Context; im ...