poj 2586

来源:互联网 发布:怎样才能增加淘宝流量 编辑:程序博客网 时间:2024/05/22 11:46

英文水平有限- -   看了好久  。。。。。也没看懂- -  后来翻了翻discuss  才知道提是啥意思

啊啊啊啊!!!


Y2K Accounting Bug
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9335 Accepted: 4647

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 237375 743200000 8496942500000 8000000

Sample Output

11628300612Deficit


题意是这样滴:

对于每一个月来说,是盈利如果则盈利S,如果亏空则亏d。每五个月进行一次统计,共统计八次(1-5月一次,2-6月一次.......)统计的结果是这八次都是亏空。问题:判断全年是否能盈利,如果能则求出最大的盈利。如果不能盈利则输出Deficit
还有需要注意的是s和d就是输入的两个数,是固定的。

理解题目什么意思了,算起来就比较简单了,分5种情况   在草纸上画一画就出来了。

#include <cstdio>#include <iostream>#include <string.h>#include <stdlib.h>#include <fstream>#include <math.h>#include <queue>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;int s,d;int sum;int main(){//freopen ("input.txt","r",stdin);while(~scanf("%d%d",&s,&d)){if(4*s<d)sum=10*s-2*d;else if(3*s<2*d)sum=8*s-4*d;else if(2*s<3*d)sum=6*s-6*d;else if(s<4*d)sum=3*s-9*d;else sum=-1;if(sum<=0) cout<<"Deficit\n";else cout<<sum<<endl;}return 0;}
else 应该是4*s>=d的情况


0 0