Y2K Accounting Bug 分类: POJ 2015-06-16 16:55 14人阅读 评论(0) 收藏
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 11222 | Accepted: 5655 |
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
对于这个题,只要分几种情况就行了
(1):当d>4*s时则十二个月最大盈利为ssssdssssdss
(2):当2*d>3*s时十二个月最大盈利为sssddsssddss
(3):当3*d>2*s时十二个月最大盈利为ssdddssdddss(4):当4*d>s时十二个月最大盈利为sddddsddddsd(5):当5*d>s时十二个月最大盈利为dddddddddddd#include <cctype>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <iostream> using namespace std; int main()
{
int s,d;
while(~scanf("%d %d",&s,&d))
{
int sum=-1;
if(d>4*s)
{
sum=10*s-2*d;
}
else if(2*d>3*s)
{
sum=8*s-4*d;
}
else if(3*d>2*s)
{
sum=6*s-6*d;
}
else if(4*d>s)
{
sum=3*s-9*d;
}
if(sum<0)
{
cout<<"Deficit"<<endl;
}
else
{
cout<<sum<<endl;
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Y2K Accounting Bug 分类: POJ 2015-06-16 16:55 14人阅读 评论(0) 收藏的更多相关文章
- ios UIKit动力 分类: ios技术 2015-07-14 12:55 196人阅读 评论(0) 收藏
UIkit动力学是UIkit框架中模拟真实世界的一些特性. UIDynamicAnimator 主要有UIDynamicAnimator类,通过这个类中的不同行为来实现一些动态特性. 它一般有两种初始 ...
- Bzoj 1036 树的统计 分类: ACM TYPE 2014-12-29 18:55 72人阅读 评论(0) 收藏
Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. Q ...
- 指向函数的指针 分类: C/C++ 2015-07-13 11:03 14人阅读 评论(0) 收藏
原文网址:http://www.cnblogs.com/zxl2431/archive/2011/03/25/1995285.html 讲的很清楚,备份记录. (一) 用函数指针变量调用函数 可以用指 ...
- Can you find it? 分类: 二分查找 2015-06-10 19:55 5人阅读 评论(0) 收藏
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...
- iOS搜索框UISearchBar 分类: ios技术 2015-04-03 08:55 82人阅读 评论(0) 收藏
当你在seachBar中输入字母之前的时候,只是用鼠标选中searchBar的时候,如图 终端输出截图如下:(这个时候调用先shouldBeginEditing,之后调用didBeginEditing ...
- hadoop调优之一:概述 分类: A1_HADOOP B3_LINUX 2015-03-13 20:51 395人阅读 评论(0) 收藏
hadoop集群性能低下的常见原因 (一)硬件环境 1.CPU/内存不足,或未充分利用 2.网络原因 3.磁盘原因 (二)map任务原因 1.输入文件中小文件过多,导致多次启动和停止JVM进程.可以设 ...
- 哈希-4 Values whose Sum is 0 分类: POJ 哈希 2015-08-07 09:51 3人阅读 评论(0) 收藏
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 17875 Accepted: ...
- 哈希-Gold Balanced Lineup 分类: POJ 哈希 2015-08-07 09:04 2人阅读 评论(0) 收藏
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13215 Accepted: 3873 ...
- 哈希-Snowflake Snow Snowflakes 分类: POJ 哈希 2015-08-06 20:53 2人阅读 评论(0) 收藏
Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 34762 Accepted: ...
随机推荐
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- js功能汇总
请编写一个JavaScript 函数toRGB,它的作用是转换CSS中常用的颜色编码. 要求: 1 alert(toRGB("#0000FF")); // 输出 rgb(0, 0, ...
- SQL 分组查询 group by
select * from emp --deptno 为部门号 --输出每个部门的编号 和 该部门的平均工资 --group by deptno; 通过deptno分组 select deptno, ...
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- android 添加背景音乐
MediaPlayer mediaPlayer=MediaPlayer.create(MainActivity.this,R.raw.qiji); mediaPlayer.start();
- the serializable class XXX does not declare a static final seriaVersionUID...的问题
关于myeclips提示The serializable class XXX does not declare a static final serialVersionUID field of typ ...
- 外部按键 控制 LED 中断 (参考 http://www.oschina.net/question/565065_115196?sort=time )
转帖: http://www.oschina.net/question/565065_115196?sort=time 实验目的: mini2440开发板上有6个按键,将其中的前4个按键设为外部中断方 ...
- Hashing function
Hashing function (散列函式) 在网页应用中被广泛采用,从数码签署.错误检测.登入验证.到压缩储存空间,由于它的原理比较复杂,很多人把它跟加密函式混淆,对于如何运用hash funct ...
- Java参数按值传递?按引用传递
有时候在想,java在调用方法时候究竟是按值传递还是按引用传递,之前有人说是基本数据类型按值传递,引用类型按引用传递.一时间,似乎都有道理. 笔者在此不追究字眼上的辨别识字能力,把自己对这个问题的理解 ...
- sql server 查询性能最差的sql语句
SELECT TOP 10 TEXT AS 'SQL Statement' ,last_execution_time AS 'Last Execution Time' ,(total_logical_ ...