题目链接:

Ball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2149    Accepted Submission(s): 897

Problem Description
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 these balls in any order on the table, one after another. Each time Jenny places a new ball on the table, he may insert it somewhere in the middle (or at one end) of the already-placed row of balls.
Additionally, each time Jenny places a ball on the table, he scores some points (possibly zero). The number of points is calculated as follows:
1.For the first ball being placed on the table, he scores 0 point.
2.If he places the ball at one end of the row, the number of points he scores equals to the number of different colors of the already-placed balls (i.e. expect the current one) on the table.
3.If he places the ball between two balls, the number of points he scores equals to the number of different colors of the balls before the currently placed ball, plus the number of different colors of the balls after the current one.
What's the maximal total number of points that Jenny can earn by placing the balls on the table?
 
Input
There are several test cases, please process till EOF.
Each test case contains only one line with 3 integers R, Y and B, separated by single spaces. All numbers in input are non-negative and won't exceed 109.
 
Output
For each test case, print the answer in one line.
 
Sample Input
2 2 2
3 3 3
4 4 4
 
Sample Output
15
33
51
 
题意:
 
给出三种球的个数,然后再求题目要求的那个最大值;
 
思路:
 
分情况讨论啦,比如现在现在三种球的个数都大于2,那么在放球的话就可以最大得到6的分数了,然后其他的情况也是这样啦;
 
AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int n,m,k;
int main()
{
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
if(n>=2&&m>=2&&k>=2)
{
LL ans=n-2+m-2+k-2;
printf("%lld\n",ans*6+15);
}
else
{
int a[4];
a[0]=n,a[1]=m,a[2]=k;
sort(a,a+3);
int num=0;
for(int i=0;i<3;i++)if(a[i]==0)num++;
if(num==3)printf("0\n");
else if(num==2)
{
if(a[2]==1)printf("0\n");
else printf("%d\n",a[2]*2-3);
}
else if(num==1)
{
if(a[2]==1)printf("1\n");
else
{
if(a[1]==1)
{
if(a[2]==1)printf("1\n");
else
{
LL ans=a[2]-2;
printf("%lld\n",3*ans+3);
}
}
else
{
LL ans=a[1]-2+a[2]-2;
printf("%lld\n",ans*4+6);
}
}
}
else
{
if(a[2]==1)printf("3\n");
else
{
if(a[1]==1)
{
LL ans=a[2]-2;
printf("%lld\n",6+ans*4);
}
else
{
LL ans=a[1]-2+a[2]-2;
printf("%lld\n",5*ans+10);
}
}
}
}
} return 0;
}

  

 

hdu-4811 Ball的更多相关文章

  1. HDU 4811 Ball 贪心

    题目链接: 题目 Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 问题描述 ...

  2. HDU 4811 Ball -2013 ICPC南京区域现场赛

    题目链接 题意:三种颜色的球,现给定三种球的数目,每次取其中一个放到桌子上,排成一条线,每次放的位置任意,问得到的最大得分. 把一个球放在末尾得到的分数是它以前球的颜色种数 把一个球放在中间得到的分数 ...

  3. [思考] hdu 4811 Ball

    意甲冠军: 有三种颜色的小珠,每种颜色的量R,Y,B 转球进入桌面成序,有多少种不同的颜色分别砍下的球在球门前+有多少身后球不同的颜色 问:最大的总比分值 思考: 球和后面的球先放好.剩下的就放中间了 ...

  4. HDU - 4811 - Ball (思维)

    题意: 给出一定数量的三种颜色的球,计算如何摆放得到值最大(有一定顺序) 有三种摆放方法 1.如果放的是第一个(桌子上原来没有),数值不变 2.如果在末尾追加一个,那么增加前面不同颜色的个数的值 3. ...

  5. Ball HDU - 4811

    Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of tho ...

  6. hdu 4811 数学 不难

    http://acm.hdu.edu.cn/showproblem.php? pid=4811 由于看到ball[0]>=2 && ball[1]>=2 && ...

  7. HDU 5821 Ball (排序)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5821 有n个盒子,每个盒子最多装一个球. 现在进行m次操作,每次操作可以将l到r之间盒子的球任意交换. ...

  8. HDU 5821 Ball (贪心)

    Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...

  9. hdu 5821 Ball 贪心

    Ball 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...

  10. HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场

    题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题 ...

随机推荐

  1. 媲美oracle awr/statspack的mysql awr第一版发布

    现发布alpha版mysql awr,其提供的特性类似于oracle awr或statspack+集中式监控.对于原来从事oracle dba或者相关运维的人原来说,这会是个不错的选择. 至于我为什么 ...

  2. springmvc+mybatis+spring 整合

    获取[下载地址]   [免费支持更新]三大数据库 mysql  oracle  sqlsever   更专业.更强悍.适合不同用户群体[新录针对本系统的视频教程,手把手教开发一个模块,快速掌握本系统] ...

  3. HTML中行内元素的竖直方向的padding和margin是否真的无效

    参考资料:Inline elements and padding 今天写一个导航栏时遇到了一个问题:行内元素的padding-top,padding-bottom和margin-top,margin- ...

  4. 在ALV中更新数据库表

    FORM usercommand USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl ...

  5. “连不上 ArcGIS License Manager ”的一点常用诊断方法

    在 ArcGIS Desktop 的问题库中,有一类不算做核心技术问题,但却可能会位列“最常见的问题”之一.简言之一句话,”许可服务器连不上怎么办?!“ 下面就来演绎下问题的诊断过程. 本文仅适用于客 ...

  6. SharePoint中Event Handler的触发

    一直以来对于Event Handler的感觉就是:添加.编辑和删除动作之前和动作之后,我们在SharePoint系统中可以做的一些事情 不过在最近处理的一个问题中,发现它在触发时机上出了一点问题   ...

  7. 自定义控件--CircleImageView(类似于QQ、微信圆形头像自定义控件)

    现在基本上所有的需要用户注册的APP都有一个需要用户上传头像的需求,上传的头像基本都是类似于QQ.微信等社交应用圆形头像.最近,正在做的一个社交应用多处需要用到这种圆形头像的处理,总不能每次都对图片做 ...

  8. JAVA基础学习day25--Socket基础二-多线程

    一.上传图片 1.1.示例 /* 上传图片 */ import java.net.*; import java.io.*; import java.util.*; import java.text.* ...

  9. IOS开发中NSRunloop跟NSTimer的问题

    在Windows时代,大家肯定对SendMessage,PostMessage,GetMessage有所了解,这些都是windows中的消息处理函数,那对应在ios中是什么呢,其实就是NSRunloo ...

  10. UVa 100 - The 3n + 1 problem(函数循环长度)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...