POJ 286 Y2K Accounting Bug【简单暴力】
链接:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 8472 | Accepted: 4185 |
Description
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
Output
Sample Input
59 237
375 743
200000 849694
2500000 8000000
Sample Output
116
28
300612
Deficit
Source
题目:
思路:
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 286 Y2K Accounting Bug【简单暴力】的更多相关文章
- 贪心 POJ 2586 Y2K Accounting Bug
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...
- POJ 2856 Y2K Accounting Bug【简单暴力】
链接: http://poj.org/problem?id=2586 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#probl ...
- poj 2586 Y2K Accounting Bug
http://poj.org/problem?id=2586 大意是一个公司在12个月中,或固定盈余s,或固定亏损d. 但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为 ...
- poj 2586 Y2K Accounting Bug (贪心)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8678 Accepted: 428 ...
- POJ 2586 Y2K Accounting Bug(枚举洪水问题)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10674 Accepted: 53 ...
- POJ 2586 Y2K Accounting Bug 贪心 难度:2
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10537 Accepted: 52 ...
- POJ 2586 Y2K Accounting Bug(枚举大水题)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10674 Accepted: 53 ...
- POJ - 2586 Y2K Accounting Bug (找规律)
Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for ...
- [POJ 2586] Y2K Accounting Bug (贪心)
题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就 ...
随机推荐
- Linux C存取效率对照——堆、栈、常量区
本文主要探讨堆和栈在使用中的存取效率.利用宏汇编指令分析訪存情况来进行简单推断. 实验环境及使用工具:i686,32位Ubuntu Linux.gcc (Ubuntu/Linaro 4.6.3-1ub ...
- ECSHOP热门搜索关键词随机显示
实现ECSHOP热门搜索关键词随机显示,需要修改ECSHOP模板和ECShOP程序,按照步骤修改即可. 一.打开 include/lib_main.php 文件,找到下面这段代码,删除之(大概在165 ...
- 2017.4.19 慕课网-通过自动回复机器人学习mybatis
开发前的分析 1.技能前提 JSP JSTL EL JS/JQUERY Servlet JavaBean JDBC(后期再用mybatis,这样体会更深) MYSQL 2.需求分析和模块划分 (1)基 ...
- phpcms前台任意代码执行漏洞(php<5.3)
phpcms v9 中 string2array()函数使用了eval函数,在多个地方可能造成代码执行漏洞 /phpsso_server/phpcms/libs/functions/global.fu ...
- HttpURLConnection读取网页文件
一.关键代码 public class MainActivity extends Activity { TextView content; ; Handler handler = new Handle ...
- react-native 项目实战 -- 新闻客户端(2) -- 完善TabBar
1.创建 drawable-xxhdpi 文件夹,保存 TabBar 的 icon图标 android -- app -- src -- main -- res -- drawab ...
- [LeetCode] Restore IP Address [28]
题目 Given a string containing only digits, restore it by returning all possible valid IP address comb ...
- 【Excle数据透视表】如何快速选定数据透视表的汇总行并添加绿色底纹
数据透视表创建好之后,如何批量将汇总行的底色修改为绿色呢?目标效果图如下: 解决方案 "启用选定内容"选取所有汇总行 单击任意汇总字段(如:北京 汇总)→选择→启用选定内容→开始→ ...
- Spring使用经验之StandardServletMultipartResolver实现文件上传的基本配置
Note:Spring使用版本是4.1.6.RELEASE 1. 在实现了AbstractAnnotationConfigDispatcherServletInitializer的类中重载custom ...
- sprint3 【每日scrum】 TD助手站立会议第七天
站立会议 组员 昨天 今天 困难 签到 刘铸辉 (组长) 在日历各个事件上都增加闹钟显示,并将数据传递给日程和时间表 调整闹钟和整个项目的显示效果,最后做出了微信界面滑动的显示效果 闹钟在广播协议的时 ...