* * POJ Y2K Accounting Bug 2586

Source: Internet
Author: User

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

Description

Accounting for computer machinists (ACM) have sufferred from the Y2K bugs and lost some vital data for preparing annual repo RT for MS Inc.
All-what they remember are that Ms Inc. posted a surplus or a deficit each month's 1999 and each month when MS Inc posted Surplus, the amount of surplus is s and each month when MS Inc. posted deficit, the deficit was d. They does 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 the these 8 postings reported a deficit but they does not know how much. The chief accountant is almost sure that MS Inc. was on 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 is possible, what is the maximum amount of surplus that they can post.

Input

Input is a sequence of lines, each containing and 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 yea R, or output deficit if it is impossible.

Sample Input

59 237375 743200000) 8496942500000 8000000

Sample Output

11628300612Deficit

Source

field=source&key=waterloo+local+2000.01.29 ">waterloo Local 2000.01.29
I didn't really understand that, test instructions probably didn't understand.

#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;elseans=s* (12-2*i)-d*2*i;if (i==5| | ans<0) cout<< "deficit" <<endl;elseprintf ("%d\n", ans);  }  return 0;}


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

* * POJ Y2K Accounting Bug 2586

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.