HDU 4811 Ball(水)
2016-08-06 21:25
316 查看
思路:水水
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
LL R,Y,B;
while(scanf("%lld%lld%lld",&R,&Y,&B)!=EOF)
{
LL RR = R>2?2:R;
LL YY = Y>2?2:Y;
LL BB = B>2?2:B;
LL hav = max((LL)0, R + Y + B - (RR+YY+BB));
cout << (hav * (RR+YY+BB) + ((RR+YY+BB) - 1) * (RR+YY+BB) / 2) << endl;
}
}
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 10 9.
Output
For each test case, print the answer in one line.
Sample Input
Sample Output
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
LL R,Y,B;
while(scanf("%lld%lld%lld",&R,&Y,&B)!=EOF)
{
LL RR = R>2?2:R;
LL YY = Y>2?2:Y;
LL BB = B>2?2:B;
LL hav = max((LL)0, R + Y + B - (RR+YY+BB));
cout << (hav * (RR+YY+BB) + ((RR+YY+BB) - 1) * (RR+YY+BB) / 2) << endl;
}
}
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 10 9.
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
相关文章推荐
- Linux升级glibc
- [leetcode]最长递增序列
- SEO
- 杭电ACM 1234开门人和关门人
- 跟我一起写Makefile(7)--- 环境变量MAKEFILES+make的工作方式
- Codeforces 703D 树状数组
- HDU 4810 Wall Painting(异或数学)
- 顺序表应用5:有序顺序表归并
- 如何批量清除128组节点db上面的过期的binlog,释放磁盘空间。(转)
- HDU-5792-World is Exploding-树状数组
- javascript-js 的prototype原型理解讲解
- squid简介
- node.js
- 对于RSA算法的一些理解
- Centos 常用命令笔记
- mysql数据库权限及编码
- 顺序表应用3:元素位置互换之移位算法
- mmap函数实现共享内存
- Java Web之Html
- refresh的停车场