博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZZULIOJ----2618: ACM-ICPC亚洲区域赛ZZULI站
阅读量:3959 次
发布时间:2019-05-24

本文共 3684 字,大约阅读时间需要 12 分钟。

题意描述:

玩了这么多游戏,V决定还是去做几道ACM题练练手,于是翻到了一道201X年ACM/ICPC亚洲区域赛某站的现场赛签到试题,但是由于多年不刷题,已经忘了怎么做了

作为将来的ACM校队扛把子的你,请帮助他解决一下吧。
现场赛题目如下:
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?

hint:对于志在区域赛的acmer们,数学思维和英语读题能力是必不可少的 : )

hint again: 感谢husy(胡胜勇)对本次周赛试题的数据测试及标程提供

输入:

多实例

输入T,表示共有T组数据(T=100)
每组数据包含三个整数R,Y,B (0<= R,Y,B <=10000)

输出:

对于每组输入,输出最高得分

样例输入:

32 2 23 3 34 4 4

样例输出:

153351

解题思路这个题就是一个模拟的过程,因为题上说总和分最大也就是每一次放球都要保证得分最大。

1、当只有一种颜色球的时候,最后得分每一次最高为2;

2、当只有两种颜色的球和其中一种颜色球只有一个时候,最后每一次得到的最高分为3;
3、当只有两种颜色的球的时候 ,最后每一次得分最高为4;
4、当其中两种颜色的球只有一个的时候,最后每次最高得分为4;
5、当一种颜色球为1个另一个颜色球为2的时候,最后每次最高得分为5;
6、当一种颜色球为1,其余都大于2的时候,最后每次得分最高为5;
7、当三种颜色球都大于2的时候,最后每次得分最高为6;

程序代码:

#include
int main(){
int i,n,m,j,k,T; long long a,b,c,sum; scanf("%d",&T); while(T--) {
sum=0; scanf("%lld%lld%lld",&a,&b,&c); n=a+b+c; if(n==0||n==1) sum=0; if(n>=2) sum+=1; if(n>=3) sum+=2; if((a==0&&b==0)||(a==0&&c==0)||(c==0&&b==0)) {
if(n>=4) sum+=2*(n-3); } else if((a==0&&b==1)||(a==0&&c==1)||(c==0&&b==1)||((c==0&&a==1)||(b==0&&a==1)||(b==0&&c==1))) {
if(n>=3) sum+=3*(n-3); } else if((a==0&&b>1)||(a==0&&c>1)||(c==0&&b>1)||((c==0&&a>1)||(b==0&&a>1)||(b==0&&c>1))) {
if(n>=4) sum+=3; if(n>=5) sum+=4*(n-4); } else if((a==1&&b==1)||(a==1&&c==1)||(c==1&&b==1)||((c==1&&a==1)||(b==1&&a==1)||(b==1&&c==1))) {
if(n>=4) sum+=3; if(n>=5) sum+=4*(n-4); } else if((a==1&&b==2)||(a==1&&c==2)||(c==1&&b==2)||((c==1&&a==2)||(b==1&&a==2)||(b==1&&c==2))) {
if(n>=4) sum+=3; if(n>=5) sum+=4; if(n>=6) sum+=5*(n-5); } else if((a==1&&b>2)||(a==1&&c>2)||(c==1&&b>2)||((c==1&&a>2)||(b==1&&a>2)||(b==1&&c>2))) {
if(n>=4) sum+=3; if(n>=5) sum+=4; if(n>=6) sum+=5*(n-5); } else if((a>=2&&b>=2&&c>=2)||(a>=2&&c>=2&&b>=2)||(a>=2&&c>=2&&b>=2)||((b>=2&&c>=2&&a>=2)||(c>=2&&b>=2&&a>=2)||(a>=2&&b>=2&&c>=2))) {
if(n>=4) sum+=3; if(n>=5) sum+=4; if(n>=6) sum+=5; if(n>=7) sum+=6*(n-6); } printf("%lld\n",sum); } return 0;}

转载地址:http://oexzi.baihongyu.com/

你可能感兴趣的文章
mysql忘记密码怎么办?~
查看>>
MySQL修改密码方法总结
查看>>
怎么将我的硬盘屏蔽
查看>>
关于MySQL select into 和 SQLServer select into
查看>>
2003应用
查看>>
文件上传组件比较
查看>>
关于MySQL select into 和 SQLServer select into
查看>>
搭建开发环境(初学liferay必看)
查看>>
Apache FileUpload文件上传组件API解析
查看>>
屏蔽usb的方法- -
查看>>
JSP编程进度条设计
查看>>
精心收集的面试笔试题库,网络上很难找到这么齐全的,推荐给大家
查看>>
教学视频
查看>>
JS操作Cookie详解
查看>>
Java正则表达式详解
查看>>
myeclipse 快捷键
查看>>
对div排序
查看>>
读写blob类型字段
查看>>
js类型转换
查看>>
spring实例化Bean理解
查看>>