Y2K Accounting Bug

Source: Internet
Author: User

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

Waterloo Local 2000.01.29
This question compares the pit. Difficult to read, s for a fixed monthly profit, d for each month fixed deficit, not five months to investigate the income and expenditure, every time for the deficit, 1-5,2-6,3-7,4-8,5-9,6-10,7-11,8-12. Altogether eight times. As long as the deficit is more applied SSSSD SSSSD SSSSSDD sssdd ssssddd ssddd sssdddd sdddd dsddddd ddddd dd So just make every five months a deficit, and finally Output total profit minus the total deficit on the line.
#include <cstdio>#include<cstring>using namespacestd;intMain () {ints,d,temp;  while(~SCANF ("%d%d",&s,&d)) {            if((4*S-D) <0) Temp=Ten*s-2*D; Else if((3*s-2*D) <0) Temp=8*s-4*D; Else if((2*s-3*D) <0) Temp=6*s-6*D; Else if(S-4*D) <0) Temp=3*s-9*D; Elsetemp =-1; if(temp>=0) printf ("%d\n", temp); Elseprintf"deficit\n"); }    return 0;}
View Code

Y2K Accounting Bug

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.