Ball HDU - 4811
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的更多相关文章
- HDU 4811 Ball 贪心
题目链接: 题目 Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 问题描述 ...
- HDU 4811 Ball -2013 ICPC南京区域现场赛
题目链接 题意:三种颜色的球,现给定三种球的数目,每次取其中一个放到桌子上,排成一条线,每次放的位置任意,问得到的最大得分. 把一个球放在末尾得到的分数是它以前球的颜色种数 把一个球放在中间得到的分数 ...
- [思考] hdu 4811 Ball
意甲冠军: 有三种颜色的小珠,每种颜色的量R,Y,B 转球进入桌面成序,有多少种不同的颜色分别砍下的球在球门前+有多少身后球不同的颜色 问:最大的总比分值 思考: 球和后面的球先放好.剩下的就放中间了 ...
- HDU - 4811 - Ball (思维)
题意: 给出一定数量的三种颜色的球,计算如何摆放得到值最大(有一定顺序) 有三种摆放方法 1.如果放的是第一个(桌子上原来没有),数值不变 2.如果在末尾追加一个,那么增加前面不同颜色的个数的值 3. ...
- hdu 4811 数学 不难
http://acm.hdu.edu.cn/showproblem.php? pid=4811 由于看到ball[0]>=2 && ball[1]>=2 && ...
- Color the ball HDU - 1556 (非线段树做法)
题意:在1到n的气球中,在不同的区域中涂颜色,问每个气球涂几次. #include<cstdio>int num[100010];int main(){ int n, x, y;; whi ...
- 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 ...
- Color the ball HDU - 1556 (线段树)
思路:线段树,区间更新 #include<iostream> #include<vector> #include<string> #include<cmath ...
- A - Color the ball HDU - 1556 (差分数组+前缀和)
思路等引自博客 https://blog.csdn.net/johnwayne0317/article/details/84928568 对数组a[7]: a[0]=1; = d[0] a[1]=1; ...
随机推荐
- 让XtraMessageBox按钮显示中文
需要定义一个继承子Localizer的类,然后重写GetLocalizedString public class MessboxClass : Localizer { public override ...
- 安装Spring Tool Suite(STS)
JAVA开发工具中,常用工具就是Eclipse,IntelliJ IDEA. 现在使用spring boot&cloud框架进行开发的时候,虽然可以使用上面两个工具,但都未必就真的量身定制,I ...
- Halcon一日一练:图像分辨率与像素
1.图像像素: 像素是指由图像的小方格即所谓的像素(pixel)组成的,这些小方块都有一个明确的位置和被分配的色彩数值,而这些一小方格的颜色和位置就决定该图像所呈现出来的样子.像素是构成图像的基本单元 ...
- 【Oracle】虚拟表Dual
Dual是个虚拟表,用来构成SELECT语句的语法规则,Oracle保证Dual里面永远只有一条记录.可以用它来做很多事情,例如,查看当前用户:用来调用系统函数:得到序列的下一个值或者当前值:可以用作 ...
- [Swift]UIKit学习之警告框:UIAlertController和UIAlertView
Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) T ...
- Pycharm 出现Unresolved reference '' 错误的解决方法
在用Pycharm做Pygame游戏小实战的时候碰到一个很无语的问题 如下 什么鬼?????? 我明明有写settings模块啊 而且还是放在同一个目录下 然后Pycharm给我来了一个错误 而且在 ...
- HDU 6035(树形dp)
题意略. 思路:有n * (n - 1) / 2这么多边,要枚举是不可能的,感觉和数据结构也沾不上边.再加上树上染色,以一条边上不同颜色作为这个边的值,这看起来像是算贡献那种题,和17icpc沈阳的某 ...
- Python自动化测试、性能测试成长路线图
Python自动化测试成长路线图 性能测试成长路线图
- NumPy学习_00 ndarray的创建
1.使用array()函数创建数组 参数可以为:单层或嵌套列表:嵌套元组或元组列表:元组或列表组成的列表 # 导入numpy库 import numpy as np # 由单层列表创建 a = np. ...
- Vscode 插件
HTML Snippets Markdown All in One Markdown PDF Markdown Priview Enhanced Markdown TOC Open HTML in D ...