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; ...
随机推荐
- 洛谷 [P3355] 骑士共存问题
二分图求最大独立点集 本问题在二分图中已处理过,此处用dinic写了一遍 #include <iostream> #include <cstdio> #include < ...
- 【WC2013】糖果公园 [树上莫队]
题意: 一棵树,修改一个点的颜色,询问两点路径上每种颜色的权值$val[c]$*出现次数的权值$cou[w[c]]$的和 sro VFK 树上莫队 按照王室联邦的方法分块,块的大小直径个数有保证,并不 ...
- BZOJ 3262: 陌上花开 [CDQ分治 三维偏序]
Description 有n朵花,每朵花有三个属性:花形(s).颜色(c).气味(m),又三个整数表示.现要对每朵花评级,一朵花的级别是它拥有的美丽能超过的花的数量.定义一朵花A比另一朵花B要美丽,当 ...
- BZOJ 3585: mex [主席树]
3585: mex Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 787 Solved: 422[Submit][Status][Discuss] ...
- 百度地图、高德地图、Google地图等坐标系相关梳理
1.地理坐标系与投影坐标系 地理坐标系也就是球面坐标系,是将本不是椭球体的地球进行椭球体化,从而形成球面坐标体系,国际标准的地理坐标系就是WGS-84坐标系: 只不过各个国家为了反映该国家所在区域地球 ...
- DNA序列组装(贪婪算法)
生物信息学原理作业第四弹:DNA序列组装(贪婪算法) 原理:生物信息学(孙啸) 大致思想: 1. 找到权值最大的边: 2. 除去以最大权值边的起始顶点为起始顶点的边: 3. 除去以最大权值边为终点为终 ...
- 从一个实例学习----FLASK-WTF
本案例通过实现一个注册页面的编写,来带你了解FLASK-WTF的运用. 主要功能为表单基础的功能--手机号码必须为11位数,且通过数据库查找不能有已经注册的了,密码要求输入两遍且必须一样,且所有内容不 ...
- linux下ACE的编译与安装
1.环境变量的设置vim /etc/profile 2.然后输入export ACE_ROOT=/root/ACE/ACE_wrappers export MPC_ROOT=$ACE_ROOT/MPC ...
- 织梦使用if判断某个字段是否为空
织梦如何使用if判断某个字段是否为空呢?我们以文章页调用文章摘要为例: 使用if语句判断摘要是否为空,如果有摘要就显示摘要模块,如果没有就不显示 {dede:field.description run ...
- OpenCV角点检测goodFeaturesToTrack()源代码分析
上面一篇博客分析了HARRIS和ShiTomasi角点检测的源代码.而为了提取更准确的角点,OpenCV中提供了goodFeaturesToTrack()这个API函数,来获取更加准确的角点位置.这篇 ...