POJ 2856 Y2K Accounting Bug【简单暴力】
来源:互联网 发布:阿里云视频 保利威视 编辑:程序博客网 时间:2024/05/01 23:32
链接:
http://poj.org/problem?id=2586
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#problem/C
Y2K Accounting Bug
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8472 Accepted: 4185
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
题目:
题意很坑,题目很水,我等弱菜+英语白痴怎么受得了
有个公司丢失了一些数据,他们的数据【盈利s,亏损d】都是每5个月报一次,所以一年当然是报 8 次了咯。
现在给你一组 s 和 d 。要你求出全年最大可能的盈利值,如果不肯能盈利则输出 Deficit
思路:
给你的数据有盈利 S 和亏损 D
那么上报一次数据的 5 个月,只可能有 5 种情况:
盈利四个月,亏损一个月:ssssd -> ssssdssssdss 【保证了对应每次报数据都是盈利四个月,亏损一月,下面同】
盈利三个月,亏损二个月:sssdd -> sssddsssddss
盈利二个月,亏损三个月:ssddd -> ssdddssdddss
盈利一个月,亏损四个月:sdddd -> sddddsddddsd
连续亏损 5 个月必定亏损= =
记得去年看过MMchen的博客Orz
code:
#include<stdio.h>int main(){ int s, d; while(scanf("%d%d", &s,&d) != EOF) { int ans = -1; if(4*s < d) ans = 10*s-2*d; //ssssd else if(3*s < 2*d) ans = 8*s-4*d; //sssdd else if(2*s < 3*d) ans = 6*s-6*d; //ssddd else if(s < 4*d) ans = 3*s-9*d; //sdddd if(ans < 0) printf("Deficit\n"); else printf("%d\n", ans); //for(int i = 1; i <= 12; i++) printf("%d\n", i*s-(12-i)*d); } return 0;}
- POJ 2856 Y2K Accounting Bug【简单暴力】
- POJ 2586 Y2K Accounting Bug 简单贪心
- POJ Y2K Accounting Bug
- 【POJ】Y2K Accounting Bug
- Y2K Accounting Bug POJ
- Y2K Accounting Bug poj
- 贪心or暴力? 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
- POJ 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- poj 2586 Y2K Accounting Bug
- struts2配置文件详解 .
- 公式记录
- linux常用命令
- 韦东山视频 笔记
- DNF盗号木马之突破令牌密保
- POJ 2856 Y2K Accounting Bug【简单暴力】
- STM32 USB Mass Storage 例程调试笔记
- Free AppleScript Code Examples
- android学习天气预报系统
- oracle的dos的操作方式
- linux C++ 多线程 堆栈
- CAT ——数列和图形
- Something you need to know about Objective-C and iOS programming: for experienced programmers
- windows8/winphone开发-判断网络链接状况