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?

InputThere 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 10 9.OutputFor 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 这题题目不难,看懂题目难! 特别是对于英语基础不好的我来说,简直是炼狱,靠猜题意为生。
题意:
有红黄蓝三种颜色的球,要求依次把球排成一列。
只有一个球的分数时为0,依次放球,放在两端的时候所加的分数为之前球颜色的种类,
把球放在中间时所加的分数为这个放的球的两边的球的颜色的种类。
    求出放完球最后的分数为多少?
这题做的方法特别多,我第一次做的时候想不出简单的方法,然后就是不断枚举,找到其中的规律。
下面放出我第一次做的代码,相信读者很容易看出其中的规律
 
 #include "cstdio"
#include "cstring"
#include <math.h>
#include "cstdlib"
#include "iostream"
#include<algorithm>
using namespace std; int main() {
long long a[];
long long sum;
while(scanf("%lld%lld%lld",&a[],&a[],&a[])!=EOF){
sort(a,a+);
sum=;
if (a[]>= && a[]>= && a[]>=) sum=+((a[]+a[]+a[])-)*;
else if (a[]== && a[]== && a[]==) sum=;
else if (a[]== && a[]== && a[]==) sum=;
else if (a[]== && a[]== && a[]>=) sum=+(a[]-)*;
else if (a[]== && a[]== && a[]==) sum=;
else if (a[]== && a[]== && a[]>=) sum=+(a[]-)*;
else if (a[]== && a[]== && a[]==) sum=;
else if (a[]== && a[]== && a[]>=) sum=+(a[]-)*;
else if (a[]== && a[]>= && a[]>=) sum=+(a[]+a[]-)*;
else if (a[]== && a[]>= && a[]>=) sum=+(a[]+a[]-)*;
printf("%lld\n",sum);
memset(a,,sizeof(a));
}
return ;
}
以上的方法是纯粹的暴力 个人感觉是非常蠢的。
下面的代码简短,就是以上代码的概括
 #include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
long long get(long long x)
{
if (x>=) return ;
else return x;
}
int main() {
long long a,b,c;
while(scanf("%lld%lld%lld",&a,&b,&c)!=EOF){
long long x=get(a)+get(b)+get(c);
long long y=a+b+c-x;
long long z=y*x+(x-)*x/;
printf("%lld\n",z);
}
return ;
}

Ball HDU - 4811的更多相关文章

  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. hdu 4811 数学 不难

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

  6. Color the ball HDU - 1556 (非线段树做法)

    题意:在1到n的气球中,在不同的区域中涂颜色,问每个气球涂几次. #include<cstdio>int num[100010];int main(){ int n, x, y;; whi ...

  7. HDU 4802 && HDU 4803 贪心,高精 && HDU 4804 轮廓线dp && HDU 4805 计算几何 && HDU 4811 (13南京区域赛现场赛 题目重演A,B,C,D,J)

    A.GPA(HDU4802): 给你一些字符串对应的权重,求加权平均,如果是N,P不计入统计 GPA Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  8. Color the ball HDU - 1556 (线段树)

    思路:线段树,区间更新 #include<iostream> #include<vector> #include<string> #include<cmath ...

  9. A - Color the ball HDU - 1556 (差分数组+前缀和)

    思路等引自博客 https://blog.csdn.net/johnwayne0317/article/details/84928568 对数组a[7]: a[0]=1; = d[0] a[1]=1; ...

随机推荐

  1. ant基础[转]

    原文链接:http://www.cnblogs.com/wufengxyz/archive/2011/11/24/2261797.html 1,什么是antant是构建工具2,什么是构建概念到处可查到 ...

  2. POJ [P3020] Antenna Placement

    二分图匹配求最小边覆盖 建图方法中的黑白染色法,题目中说信号可以覆盖相邻两个块,那么我们可以将给定的地图染成国际象棋棋盘的样子,一个黑格可以与周围的四个白格共用信号,对于城市,从每一个黑格出发,向其周 ...

  3. selenium headlesschrome下设置最大窗口模式

    做微博登录的时候,用selenium的chrome界面模式,可以用下面方式显示最大窗口: from selenium.webdriver.chrome.options import Options c ...

  4. 如何解决JavaScript中0.1+0.2不等于0.3

    console.log(0.1+0.2===0.3)// true or false?? 在正常的数学逻辑思维中,0.1+0.2=0.3这个逻辑是正确的,但是在JavaScript中0.1+0.2!= ...

  5. nginx的location优先级

    在nginx配置文件中,location主要有这几种形式: 1. 正则匹配 location ~ /abc { } 2. 不区分大小写的正则匹配 location ~* /abc { } 3. 匹配路 ...

  6. Swift iOS 日期操作:NSDate、NSDateFormatter

    1.日期(NSDate) // 1.初始化 // 初始化一个当前时刻对象 var now = NSDate() // 初始化一个明天当前时刻对象 var tomorrow = NSDate(timeI ...

  7. IntelliJ IDEA(八) :git的使用

    项目管理离不开版本控制,目前主流版本控制工具大概就是SVN和Git,至于两者有啥区别这里就不详细介绍了,如果有不明白的可以上网查资料,后期如果有机会我再开篇栏目细说,而且现在市场上Git的使用率已经远 ...

  8. 框架学习笔记之Maven简介和配置

    一.什么是Maven?★Maven可翻译为“知识的积累”.“专家”.“内行”,它是一个跨平台的项目管理工具.★Maven提供了开发人员构建一个完整的生命周期框架,开发团队可以自动完成项目的基础工具建设 ...

  9. CSS 圣杯布局升级版---多个固定宽度一个自适应宽度

    1.一个div固定,一个div自适应宽度.两种情况,固定在左或者在右. HTML: <div class="box1"> <div class="mai ...

  10. CentOS常用命令搜集

    centos是32或者64位:getconf LONG_BIT