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

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

题目看不懂是硬伤,还一直以为每个月的surplus , deficit不一样;orz(最欠的就是这里,一样还报个p啊)
posts their earnings for each consecutive 5 months during a year 这句话的理解:每5个月 的 意思是 1 ~ 5 ,2 ~ 6 , 3 ~ 7……8 ~ 12 orz
这也解释了为毛会得到8张单子。
 #include<stdio.h>
int s , d ; int main ()
{
// freopen ("a.txt" , "r" , stdin) ;
int i , earn , two;
while (~ scanf ("%d%d" , &s , &d)) {
for (i = ; i < ; i++) {
if (i * d > ( - i) * s)
break ;
}
two = ;
if (i == )
two = ;
if (i == ) {
puts ("Deficit") ;
continue ;
}
earn = ( - * i - two) * s - ( * i + two ) * d ;
if (earn < ) {
printf ("Deficit\n") ;
}
else
printf ("%d\n" , earn ) ;
}
return ;
}

Y2K Accounting Bug(贪心)的更多相关文章

  1. poj 2586 Y2K Accounting Bug (贪心)

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

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

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

  3. POJ2586 Y2K Accounting Bug(贪心)

    题目链接. 题目大意: 题目相当晦涩难懂啊. 一年的12个月,每5个月统计一次,如从1~5,2~6,3~7,...,8~12共统计了8次,已知每次都deficit,问这一年有没有盈利的可能. 一个月s ...

  4. POJ-2586 Y2K Accounting Bug贪心,区间盈利

    题目链接: https://vjudge.net/problem/POJ-2586 题目大意: MS公司(我猜是微软)遇到了千年虫的问题,导致数据大量数据丢失.比如财务报表.现在知道这个奇特的公司每个 ...

  5. poj 2586 Y2K Accounting Bug(贪心算法,水题一枚)

    #include <iostream> using namespace std; /*248K 32MS*/ int main() { int s,d; while(cin>> ...

  6. 贪心 POJ 2586 Y2K Accounting Bug

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

  7. poj2586 Y2K Accounting Bug(贪心)

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

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

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

  9. 贪心 --- Y2K Accounting Bug

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9691   Accepted: 483 ...

随机推荐

  1. JavaScript里面三个等号和两个等号有什么区别?

    1.对于string,number等基础类型,==和===是有区别的 a)不同类型间比较,==之比较“转化成同一类型后的值”看“值”是否相等,===如果类型不同,其结果就是不等 b)同类型比较,直接进 ...

  2. C#异步编程一

    前几天把Code First系列总结完,想着下步总结什么,原本想着XML,不过XML的内容比较多,还有3天班就中秋节了,想在中秋节前在完成一个系列,所以决定把异步这块总结下.说起异步可能会认为就是多线 ...

  3. Windows Phone8 中如何引用 SQLite 数据库2

    本博文编写环境 VS2013 + WP8 SDK 上篇介绍完了SQLite在wp中的部署(具体请参阅 Windows Phone8 中如何引用 SQLite 数据库),下面来看如何使用 SQLite ...

  4. javascript 规范

    关于变量及方法等的命名,没有硬性规定,但是为了规范,遵循一些约定还是有必要的. 变量定义: 用var 关键字将要使用的变量定义在代码开头,变量间用分号隔开. 原因有二: 一是便于理解,知道下面的代码会 ...

  5. Hibernate-Criteria用法

    criteria 英[kraɪˈtɪərɪə] 美[kraɪˈtɪrɪə] Hibernate 设计了 CriteriaSpecification Hibernate 设计了 CriteriaSpec ...

  6. Java Filter过滤器的简单总结

    1.Filter的介绍 Filter技术是servlet 2.3新增加的功能.它能够对Servlet容器的请求和响应对象进行检查和修改. Filter本身并不生成请求和响应对象,只是提供过滤功能. F ...

  7. 13. (转) Android一些布局属性详解

    RelativeLayout用到的一些重要的属性: 第一类:属性值为true或false     android:layout_centerHrizontal  水平居中      android:l ...

  8. BZOJ-2049 Cave洞穴勘测 动态树Link-Cut-Tree (并查集骗分TAT)

    2049: [Sdoi2008]Cave 洞穴勘测 Time Limit: 10 Sec Memory Limit: 259 MB Submit: 5833 Solved: 2666 [Submit] ...

  9. javascript-如何判断一个对象为数组

    Q:如何判断一个对象是否为数组? A1:判断对象的constructor是否指向Array, 接着判断对应的特殊属性,如length,splice之类.这个很容易冒充. A2:使用instanceof ...

  10. java + jquery + ajax + json 交互

    前端js部分: $.ajax({ async:true, cache:false, type:"POST", dataType : 'json', url:"/shopp ...