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. C语言深度剖析-笔记

    关键字: C语言关键字32个: 关键字                                         意 义 auto                           声明自动变 ...

  2. java windows自动化-mail自动发邮件

    本文旨在让测试人员了解如何发邮件 发邮件的话,最简单的事是直接手动发邮件,但是在自动化测试中,应做到让机器或者代码来自动发送邮件,笔者大概了解以下几种方法,总有一款口味适合你:1java代码来做下面即 ...

  3. Windows Server 2016-部署额外域控制器

    我们一般所提到的所谓域外控制器,是指除域内第一台域控制器之外的其他域控制器.额外域控制器很多时候也有辅助域控一称.那么在同一域内安装多台域控制器有什么优点呢: 1.提高用户登录效率.多台域控制器可以同 ...

  4. jQuery源码逐行分析学习02(第一部分:jQuery的一些变量和函数)

    第一次尝试使用Office Word,方便程度大大超过网页在线编辑,不过初次使用,一些内容不甚熟悉,望各位大神见谅~ 在上次的文章中,把整个jQuery的结构进行了梳理,得到了整个jQuery的简化结 ...

  5. HashSet和CopyOnWriteArraySet

    前言 这篇文章的目的如下: HashSet是如何保证元素的不重复和无序 HashSet的增删(改查?)原理 CopyOnWriteArraySet支持并发的原理 CopyOnWriteArraySet ...

  6. IOS设备设计完整指南

    作为初学者,常常不知如何下手设计,IOS应用UI设计中碰到的种种基础小问题,在此都将一一得到解答.这份完整的设计指南将带你快速上手,为IOS设计出优雅的应用吧. 关于此设计指南 此设计指南描述的是如何 ...

  7. javascript函数大全

    JavaScript函数大全 1.document.write(""); 输出语句2.JS中的注释为//3.传统的HTML文档顺序是:document->html->( ...

  8. Linux系统内存占用90%以上——解决方法

    Linux系统内存占用90%以上--解决方法   首先要明确一个问题:Linux系统内存占用90%以上,是否属于正常范围?网上有详细的解释,这属于正常现象~~~    www.2cto.com   L ...

  9. go get报错unrecognized import path “golang.org/x/net/context”…

    今天安装gin框架,首先下载gin,命令如下:go get github.com/mattn/go-sqlite3 结果报错: package golang.org/x/net/context: un ...

  10. 批量修改git仓库地址脚本

    前言   公司的代码都存放在自己搭建的gitlab上面.之前由于老板升级gitlab.导致下面有个叫做"api"的groups无法访问.通过无所不能的谷歌才知道.在gitlab在某 ...