题目链接:

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. 爱你.一万年>>数据库基础

    嗨!最近学习了一项新的技能,学习了数据库的知识,在这里抛砖引玉,给大家说说,望赐教!!>> 01.首先给大家谈谈为什么要使用数据库? 数据库可以看成是一个永久保存数据的仓库. 可以存储大量 ...

  2. [.NET] 使用C#开发SQL Function来提供数据 - 天气预报

    [.NET] 使用C#开发SQL Function来提供数据 - 天气预报 范例下载 范例程序代码:点此下载 问题情景 开发人员在设计一些数据汇整的系统服务时,可能会选择WCF.WebAPI.Sign ...

  3. asp.net webform 与mvc 共享session

    公司内部系统最早是用.net webform模式开发的,现新项目用.net mvc 开发,现存在的问题就是如何保持原有.net webform的登录状态不变,而在mvc中能够验证用户的登录状态,也就是 ...

  4. CSS3边框温故

    1.简介:border属性在CSS1中就已经定义了,用来设置元素边框风格,设置不同的边框.颜色.粗细 2.基本属性,包括三个类型值:(1)border-width:设置元素边框的粗细,默认3~4px( ...

  5. An unexpected error has occurred" error appears when you try to create a SharePoint Enterprise Search Center on a Site Collection

    The Enterprise Search Center requires that the Publishing feature be enabled. To enable the Publishi ...

  6. Nunit在VS2010加载不了程序集的解决办法

    本机环境: Win7 64位 旗舰版 VS2010 Nunit2.6.3 故障重现步骤: 1.在启动外部应用程序中增加C:\Program Files (x86)\NUnit 2.6.3\bin\nu ...

  7. JSP基础--JAVA遇见HTML

    1.手工编写第一个WEB应用程序 2.默认访问服务器网页首页欢迎界面是 index.jsp,就是网页链接访问其所在的文件夹目录,不访问这个文件,也会自动访问的.如果这个文件夹目录下没有index.js ...

  8. java获取时间戳的方法

    JAVA 获取当前月的初始时间的时间戳 public static long getMonthFirstDay() { Calendar calendar = Calendar.getInstance ...

  9. android textview 设置不同的颜色和大小

    1.定义不同的style <style name="approval_detail_info_style1"> <item name="android: ...

  10. openstack 上床镜像, 创建网络, 创建虚拟机 命令

    ==================================================================================================== ...