POJ-2586-Y2K Accounting Bug
来源:互联网 发布:电脑版电视直播软件 编辑:程序博客网 时间:2024/06/04 00:26
Y2K Accounting Bug
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 13247 Accepted: 6725
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.
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
Source
Waterloo local 2000.01.29
// 英语是硬伤,完全看不懂题意 ||-_-#include <iostream>#include<stdio.h>#include<string.h>#include<math.h>using namespace std;int surplus, deficit, a[12], sum5[8], sum12;void add(int x){ int flag = 1; for(int i = 0; i<8; ++i) if(x>=i&&x<i+5) { sum5[i]+=deficit+surplus; if(sum5[i]>=0)flag = 0; } if(!flag) { for(int i = 0; i<8; ++i) if(x>=i&&x<i+5) sum5[i]-=(deficit+surplus); } else a[x] = surplus;}int main(){ while(~scanf("%d %d", &surplus, &deficit)) { for(int i = 0; i<12; ++i) a[i] = -deficit; for(int i = 0; i<8; ++i) sum5[i] = -5*deficit; for(int i = 0; i<12; ++i) add(i); sum12 = 0; for(int i = 0; i<12; ++i) sum12+=a[i]; if(sum12>0)printf("%d\n", sum12); else printf("Deficit\n"); } return 0;}
0 0
- POJ 2586 Y2K Accounting Bug
- poj-2586-Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- poj - 2586 - Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- POJ 2586 Y2K Accounting Bug
- ** poj Y2K Accounting Bug 2586
- poj 2586 Y2K Accounting Bug
- android-Notification.Action
- poj 1456 Supermarket 贪心 并查集优化
- APP开发实战117-APP图片优化
- android Binder 学习 博客链接
- 【ES6学习笔记】-----箭头函数与symbol
- POJ-2586-Y2K Accounting Bug
- **MYSQL** 系列六
- Android for work总结(上)
- QGraphicsPixmapItem与QGraphicsScene的编程实例 图标拖动渐变效果
- python笔记---需求文件requirements.txt的创建及使用
- JHTP小结_第十二章_GUI组件(上篇)-Part 2
- Torch7学习(五)——学习神经网路包的用法(3)
- nginx+uwsgi 部署django
- 关于android程序进入第一个界面出现空白的解决方案