2013南京站J题||hdu 4811 思维
来源:互联网 发布:我想在淘宝上做代理商 编辑:程序博客网 时间:2024/04/30 14:46
http://acm.hdu.edu.cn/showproblem.php?pid=4811
Problem 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?
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 109.
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 109.
Output
For each test case, print the answer in one line.
Sample Input
2 2 23 3 34 4 4
Sample Output
153351
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;ll f[3],k;ll sum[3][3][3];int main(){ sum[0][0][0]=0; sum[0][0][1]=0; sum[0][0][2]=1; sum[0][1][1]=1; sum[0][1][2]=3; sum[0][2][2]=6; sum[1][1][1]=3; sum[1][1][2]=6; sum[1][2][2]=10; sum[2][2][2]=15; while(~scanf("%I64d%I64d%I64d",&f[0],&f[1],&f[2])) { ll n=0,m=0; sort(f,f+3); for(int i=0;i<3;i++) { if(f[i]>2) k=2; else k=f[i]; n+=f[i]-k,f[i]=k; m+=f[i]; } printf("%I64d\n",sum[f[0]][f[1]][f[2]]+n*m); } return 0;}
Problem 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?
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 109.
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 109.
Output
For each test case, print the answer in one line.
Sample Input
2 2 23 3 34 4 4
Sample Output
153351
0 0
- 2013南京站J题||hdu 4811 思维
- hdu 4810 思维题+二进制位规律+异或规律 213南京现场赛题
- J. Panoramic Photography----思维题
- 2013ACM/ICPC亚洲区南京站现场赛 HDU 4802 && HDU 4803 && HDU 4811 && HDU 4812
- 2013长沙站J题||hdu 4800 dp
- NJUST 1746 Similar Number(南京邀请赛 J题)
- HDU 4473 Exam 2012成都现场赛J题(规律+思维)
- hdu 4810 2013南京区域赛 杨辉三角组合数+容斥原理思维+找规律
- HDU 4588 2013 ACM/ICPC 南京邀请赛 C 题
- hdu 4811 Ball 思维题
- 2013acm南京站
- hdu 4821 ||2013年长春站J题 字符串哈希+map的应用
- HDU 4585 Shaolin(2013杭州邀请赛J题-二分)
- hdu 5101 思维题
- hdu 5744 思维题
- hdu 5873 思维题
- HDU 5963 思维题
- HDU 5969 思维题
- 人行横道作出了应用搜索过程中容易在iOS
- Oracle几个常用的伪列(Pseudo-column)使用
- 你的第一本哲学书 -- 7、公正 ---- 托马斯·内格尔
- 如何注册公司在Vizag港,公司成立在维沙卡帕特南
- 【Android】手动显示和隐藏软键盘
- 2013南京站J题||hdu 4811 思维
- API、DLL、SDK
- 《Python 核心编程》 第三章习题 3.10
- 修改目录里面的.jpg结尾的文件改为.png (pid system fgets fork)
- 你的第一本哲学书 -- 8、死亡 ---- 托马斯·内格尔
- 嵌入式 关于sqlite多线程编程相关小结
- Linux 可执行文件 ELF结构 及程序加载运行
- 你的第一本哲学书 -- 9、生活的意义 ---- 托马斯·内格尔
- popen