HDU 4811 Ball(贪心)
来源:互联网 发布:锁扣地板 知乎 编辑:程序博客网 时间:2024/04/30 17:47
题意:
给你三种颜色的球若干,让你制定一个安防策略,使得你的分数最高分的规则是:当前安放的球前面的颜色的种类a+后面的颜色的种类b(不包括本身)
首先我们肯定是把球往中间放,如果能够让前面后面都有三种颜色的话,那剩下的球的分数都是固定的,所以说我们只要先构造出一种情况是的前面后面的不同颜色种数最多即可,剩下的就直接算了。
代码:
//// Created by CQU_CST_WuErli// Copyright (c) 2016 CQU_CST_WuErli. All rights reserved.//#include <iostream>#include <cstring>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <string>#include <vector>#include <list>#include <map>#include <queue>#include <stack>#include <set>#include <algorithm>#include <sstream>#define CLR(x) memset(x,0,sizeof(x))#define OFF(x) memset(x,-1,sizeof(x))#define MEM(x,a) memset((x),(a),sizeof(x))#define BUG cout << "I am here" << endl#define lookln(x) cout << #x << "=" << x << endl#define SI(a) scanf("%d",&a)#define SII(a,b) scanf("%d%d",&a,&b)#define SIII(a,b,c) scanf("%d%d%d",&a,&b,&c)#define rep(flag,start,end) for(int flag=start;flag<=end;flag++)#define Rep(flag,start,end) for(int flag=start;flag>=end;flag--)#define Lson l,mid,rt<<1#define Rson mid+1,r,rt<<1|1#define Root 1,n,1#define BigInteger bignconst int MAX_L=2005;// For BigIntegerconst int INF_INT=0x3f3f3f3f;const long long INF_LL=0x7fffffff;const int MOD=1e9+7;const double eps=1e-9;const double pi=acos(-1);typedef long long ll;using namespace std;ll r,y,b;int main(int argc, char const *argv[]) {#ifdef LOCAL freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin); // freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);#endif while(cin >> r >> y >> b) { ll ans=0; int pre,suf; pre=suf=0; if (r) pre++,r--; if (y) pre++,y--; if (b) pre++,b--; if (r) suf++,r--; if (y) suf++,y--; if (b) suf++,b--; if (pre==suf) { if (pre==0) ans=0; else if (pre==1) { ans+=1; ans+=(r+y+b)*2; } else if (pre==2) { ans=6; ans+=(r+y+b)*4; } else { ans=15; ans+=(r+y+b)*6; } } else { if (pre==3 && suf==2) { ans=10; ans+=(r+y+b)*5; } else if (pre==3 && suf==1) { ans=6; ans+=(r+y+b)*4; } else if (pre==3 && suf==0) { ans=3; ans+=(r+b+y)*3; } else if (pre==2 && suf==1) { ans=3; ans+=(r+y+b)*3; } else if (pre==2 && suf==0) { ans=1; ans+=(r+y+b)*2; } else if (pre==1 && suf==0) { ans=0; ans+=(r+y+b)*1; } } cout << ans << endl; } return 0;}
0 0
- HDU 4811 Ball(贪心)
- HDU 4811 Ball(贪心)
- HDU 5821 Ball(贪心)
- [HDU 5821] Ball (贪心)
- HDU 5821 Ball (贪心)
- HDU 5821 Ball ( 贪心)
- HDU-5821-Ball(贪心)
- HDU 5821 Ball(贪心)
- HDU 5821 Ball(贪心)
- 贪心(Ball,HDU 5821)
- hdu 5821 Ball 贪心(多校)
- Hdu-5821 Ball(贪心)
- HDU 5821 Ball【贪心】
- HDU 5821 Ball 贪心
- HDU 5821 Ball 贪心+映射
- HDU 5821-A - Ball-贪心
- Hdu 5821 Ball 贪心+模拟
- hdu 5821 Ball 贪心+思维
- 集成了Laravel的Eloquent ORM的Yaf框架
- 欢迎使用CSDN-markdown编辑器
- 遍历Text字符
- ContentProvider 报线程错误
- [BZOJ2298] [HAOI2011]problem a
- HDU 4811 Ball(贪心)
- 通过汇编分析c程序函数调用的原理
- 【JAVA】23、方法的递归调用
- 纯化水系统安装与使用注意点
- 构建微服务-第一章-什么是微服务_006关于SOA
- LayoutInflater简单理解
- android gif动画开源框架android-gif-drawable
- 从C++转向java——5、数组
- 朱七七:为爱而生,浮沉随浪