[思路] hdu 4811 Ball

题意:

有三种颜色的小球,每种颜色数量R,Y,B

依次把球放到桌面上成一个序列,每次得分为这个球前面有多少种不同颜色的球+后面有多少种不同颜色的球

问总得分的最大值

思路:

构造前面的球和后面的球先放好,剩下的就放中间了

代码:

#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"queue"
#include"algorithm"
#include"map"
#include"vector"
#include"string"
#define inf 0x7fffffff
#include"iostream"
#define ll __int64
using namespace std;
ll f1[]={0,0,1,3};
int main()
{
    ll r,y,b;
    while(cin>>r>>y>>b)
    {
        ll qian=0,hou=0;
        ll ans=0;
        if(r>0) { qian++; r--; }
        if(y>0) { qian++; y--; }
        if(b>0) { qian++; b--; }
        if(r>0) { hou++; r--; }
        if(y>0) { hou++; y--; }
        if(b>0) { hou++; b--; }
        ans+=f1[qian];
        ans+=qian*hou+f1[hou];
        ans+=(qian+hou)*(r+b+y);
        printf("%I64d\n",ans);
    }
    return 0;
}
时间: 2024-07-31 18:16:54

[思路] hdu 4811 Ball的相关文章

hdu 4811 Ball(数学)

题目链接:hdu 4811 Ball 题目大意:有三种颜色的球若干,每次向桌子上放一个球,保证是一条序列,每次放球的得分为当前放入序列的球的前面有多少种不同的颜色a,后面的有多少种不同的颜色b,a+b.问说给定球的数量后,最大得分为多少. 解题思路:因为放球顺序是自己定的,所以我们可以尽量早得构造一个序列,使得后面放入球的得分均保持在峰值.那么求峰值就要根据球的数量来决定.我们叫得分为峰值的求为最高得分球,它们有很多个.对于一种颜色来说:0个,表示不能为在最高得分球的左边和右边,换句话来说,就是

HDU 4811 Ball(贪心)

2014-05-15 22:02 by Jeff Li 前言 系列文章:[传送门] 马上快要期末考试了,为了学点什么.就准备这系列的博客,记录复习的成果. 正文-计数  概率 概率论研究随机事件.它源于赌徒的研究.即使是今天,概率论也常用于赌博.随机事件的结果是否只凭运气呢?高明的赌徒发现了赌博中的规律.尽管我无法预知事件的具体结果,但我可以了解每种结果出现的可能性.这是概率论的核心. "概率"到底是什么?这在数学上还有争议."频率派"认为概率是重复尝试多次,某种结

Ball HDU - 4811

Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, Jenny has R red balls, Y yellow balls and B blue balls. He may put

hdu 4811 数学 不难

http://acm.hdu.edu.cn/showproblem.php?pid=4811 因为看到ball[0]>=2 && ball[1]>=2 && ball[2]>=2  ans=(sum-6)*6+15    sum是三种颜色的球个数的和,然后就想到分类讨论,因为情况是可枚举的, 发现整数如果不加LL直接用%I64d打印会出问题 //#pragma comment(linker, "/STACK:102400000,102400000

hdu 5821 Ball(2016 Multi-University Training Contest 8——贪心+排序)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5821 Ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 515    Accepted Submission(s): 309 Problem Description ZZX has a sequence of boxes numbe

hdu 5821 Ball (贪心)

Ball Description ZZX has a sequence of boxes numbered 1,2,...,n. Each box can contain at most one ball. You are given the initial configuration of the balls. For 1 \leq i \leq n, if the i-th box is empty then a[i]=0, otherwise the i-th box contains e

[水+思路] hdu 3682 To Be an Dream Architect

题意: 就是有n*n*n个木块,然后给你m条三维的直线 问这些直线能够消掉多少个木块 思路: 其实就是求m条直线有几个交点 然后就是一个双重循环解决 然后读入的时候需要判重 用三个1000*1000的数组来实现. 注意 3 3 Y=2,Z=2 X=2,Y=2 X=2,Z=2 答案应该是7而不是6,因为三条线交在同一点上. 6的原因是在判断第一条线的时候 和后面两个都有交点,但是交点是同一个 其实只有1个. 这里的判重方法就是,用这条线没有的那个坐标进行判重. 因为对于Y=2,Z=2 交点的话只有

hdu 4771 13 杭州 现场 B - Stealing Harry Potter's Precious 暴力bfs

Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. When Hogwarts school is in holiday, Harry Potter has to go back to uncle Vernon's home. But he can't bring his precious with him. As you know, uncle Ve

2013nanjingJ

J - Ball Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4811 Appoint description:  System Crawler  (2014-10-08) Description Jenny likes balls. He has some balls and he wants to arrange them in