POJ 2856 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 2856 Y2K Accounting Bug【简单暴力】的更多相关文章
- 贪心 POJ 2586 Y2K Accounting Bug
题目地址:http://poj.org/problem?id=2586 /* 题意:某公司要统计全年盈利状况,对于每一个月来说,如果盈利则盈利S,如果亏空则亏空D. 公司每五个月进行一次统计,全年共统 ...
- POJ 286 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元,如果赔钱的话,就 ...
随机推荐
- Webpack打包工具学习使用
Webpack 是当下最热门的前端资源模块化管理和打包工具.它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源.还可以将按需加载的模块进行代码分隔,等到实际需要的时候再异步加载.通过 ...
- crontab配置
1.命令功能 通过crontab 命令,我们可以在固定的间隔时间执行指定的系统指令或 shell script脚本.时间间隔的单位可以是分钟.小时.日.月.周及以上的任意组合.这个命令非常适合周期性的 ...
- Oracle基础 PL-SQL编程基础(2) 分支结构
一.分支结构 1.if语句 语法: IF <布尔表达式> THEN PL/SQL和SQL语句 END IF; 示例: DECLARE v_count NUMBER := &n; B ...
- 解决ie7下overflow:hidden失效问题
但父亲元素下面的子节点或者孙子节点有position:relative:或者absolute时,父亲即使设置了overflow:hidden:依然会溢出 解决方法可以: 在父亲元素上加上*positi ...
- Python中的import和from import
一.Python路径介绍 在python用import或者from...import来导入相应的模块. 模块其实就是一些函数和类的集合文件,它能实现一些相应的功能,当我们需要使用这些功能的时候,直接把 ...
- cpu、内存、磁盘
例一:内存使用率 #!/bin/bash total=$(free -m|grep Mem|awk '{print $2}') used=$(free -m|grep Mem|awk '{print ...
- USB驱动 | win10下使用console线错误代码10解决办法
驱动安装后如果无法使用,错误代码10, 原因:系统自动安装了新版本的驱动,回滚到老版本即可
- mongo: 改
语法:db.CollectionName.upadte(查询表达式,新值,选项); 查询表达式:定位哪些列是要被修改的列(即使查询表达式能命中多行,默认也只改一行,如果想改多行,可以用multi选项, ...
- Android XMPP 即时通讯
0 http://blog.csdn.net/lnb333666/article/details/7471292 0.1 http://www.cnblogs.com/charley_yang/arc ...
- PHP之十六个魔术方法详细介绍
PHP中把以两个下划线__开头的方法称为魔术方法(Magic methods),这些方法在PHP中充当了举足轻重的作用.这里进行详细介绍,感兴趣的小伙伴们可以参考一下. PHP中把以两个下划线__开头 ...