poj2586 (盈亏计算贪心)
来源:互联网 发布:淘宝潮牌店铺推荐 编辑:程序博客网 时间:2024/05/02 02:03
分5种情况讨论
y表示至少几次盈余才能一年后赚钱
x表示5个月最多盈余几次这5个月才亏钱
x从0到4讨论 ,找出每种情况下最多的盈余月数,与y比较,若大于等于y才、,则可以,否则不行
#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>#include<map>#include<queue>#include<math.h>using namespace std;#define LL long long#define mp(a,b) make_pair((a),(b))#define clr(x,a) memset(x,a,sizeof(x))#define INF 0x3f3f3f3f#define lb(x) ((x)&(-x))const int N=1005,siz=1e9;const int MOD=1e9+7;int s,d;int main(){ //freopen("aaa.txt","r",stdin); //freopen("bbb.txt","w",stdout); int T; while(~scanf("%d%d",&s,&d)){ int y=12*d/(s+d)+1; int x=5*d/(s+d); int num=0; int i=1,j=12; //cout<<x<<endl<<y<<endl; bool ok; LL tmp; if(x==0) ok=0; else if(x==1) {ok=(3>=y);tmp=3;} else if(x==2) {ok=(6>=y);tmp=6;} else if(x==3) {ok=(8>=y);tmp=8;} else if(x==4) {ok=(10>=y);tmp=10;} LL ans; if(ok) ans=tmp*s-(12-tmp)*d; if(ok) printf("%I64d\n",ans); else puts("Deficit"); } return 0;}
0 0
- poj2586 (盈亏计算贪心)
- POJ2586--贪心
- poj2586 贪心
- POJ2586(贪心)
- poj2586贪心
- POJ2586(贪心)
- 贪心poj2586
- poj2586 Y2K Accounting Bug(贪心)
- poj2586(贪心问题,区间盈利类型)
- POJ2586--Y2K Accounting Bug(贪心)
- POJ2586 Y2K Accounting Bug(贪心)
- poj2586 典型贪心
- poj2586 贪心算法
- poj2586——Y2K Accounting Bug(贪心)
- 【贪心】POJ2586 Y2K Accounting Bug
- poj2586 Y2K Accounting Bug 贪心
- POJ2586 Y2K Accounting Bug(贪心)
- POJ2586 Y2K Accounting Bug 贪心
- PCIE 设备扫描的过程
- 通过调用Twitter API抓取Twitter数据
- ios上取得设备唯一标志的解决方案
- Cocos2d-x背景的循环滚动
- 第十六周 时间的格式化
- poj2586 (盈亏计算贪心)
- OC学习篇之---@property和@synthesize的使用
- Android HttpsURLConnection上送Base64过的图片遇到的奇葩问题
- 九度OJ 1063 整数和 (模拟)
- SAX解析XML并把节点值保存到相应的对象中
- Princeton Algorithms: Part 2 [week 6: Regular Expressions]
- Linux下的Notepad++编辑器——Notepadqq
- 黑马程序员java自学总结之--集合
- 黑马程序员--IOS_学习笔记_内存管理_@autorelease