HDU
来源:互联网 发布:双色球蓝球算法 编辑:程序博客网 时间:2024/05/29 08:26
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?
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.
2 2 23 3 34 4 4
153351
比较简单,不详细说了
ac代码:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int main(){ int x,y,z; long long sum; int k; while(scanf("%d%d%d",&x,&y,&z)!=-1) { k=0; sum=x+y+z; int g=0; if(x>0) g++; if(y>0) g++; if(z>0) g++; if(x>=2) { k+=2; sum-=2; } else { k+=x; sum-=x; } if(y>=2) { k+=2; sum-=2; } else { k+=y; sum-=y; } if(z>=2) { k+=2; sum-=2; } else { k+=z; sum-=z; } if(k==0||k==1) cout<<0<<endl; if(k==2) { if(g==1) cout<<1+sum*2<<endl; if(g==2) cout<<1<<endl; } if(k==3) { if(g==2) cout<<3+3*sum<<endl; if(g==3) cout<<3<<endl; } if(k==4) { cout<<6+sum*4<<endl; } if(k==5) { cout<<10+sum*5<<endl; } if(k==6) cout<<15+sum*6<<endl; } return 0;}
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock
- socket阻塞与非阻塞,同步与异步、I/O模型
- blackfriday markdown的自动换行 go lang 正则替换字符串时遇到的坑,转义解析其中的 $1 $name 等
- myisam和innodb对比
- 利用广义表解决下列多项式的存储问题
- HDU
- apache cxf-2.4.3 +spring-3.0.5发布SOAP协议WebService服务
- markdown设置字体颜色、大小、背景
- Android日期控件
- Mac bash 调用系统对话框
- Junit4-Fixture
- jQuery列表多条件商品查询(仿淘宝)
- POJ 2481 Cows (树状数组)
- 关于粤语