博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2013nanjingJ
阅读量:6247 次
发布时间:2019-06-22

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

J - Ball
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit     
Appoint description: System Crawler  (2014-10-08)

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
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #define M(a,b) memset(a,b,sizeof(a)) 8 #include
9 using namespace std;10 11 long long R,Y,B;12 13 int main()14 {15 while(scanf("%I64d%I64d%I64d",&R,&Y,&B)==3)16 {17 long long ans = 0;18 if(R>=2&&Y>=2&&B>=2) //全大于119 ans = (R+Y+B-6)*6+15;20 else21 {22 if(R==1&&Y>1&&B>1||Y==1&&R>1&&B>1||B==1&&Y>1&&R>1) //一个1其余大于123 {24 ans = (R+Y+B-5)*5+10;25 }26 else if(R==1&&Y==1&&B>1||B==1&&Y==1&&R>1||R==1&&B==1&&Y>1) //两个1一个大于127 {28 ans = (R+Y+B-4)*4+6;29 }30 else if(R==1&&Y==1&&B==1) //3个131 {32 ans = 3;33 }34 else if(R==0&&Y>1&&B>1||B==0&&Y>1&&R>1||Y==0&&B>1&&R>1) //1个035 {36 ans = (R+Y+B-4)*4+6;37 }38 else if(R==0&&Y==0&&B>1||B==0&&Y==0&&R>1||R==0&&B==0&&Y>1)//2个039 {40 ans = (R+B+Y-2)*2+1;41 }42 else if(R==0&&Y==1&&B>1||R==1&&Y==0&&B>1||B==1&&Y==0&&R>1||B==0&&Y==1&&R>1||R==0&&B==1&&Y>1||B==0&&R==1&&Y>1) //1个0,1个143 {44 ans = (R+B+Y-3)*3+3;45 }46 else if(R==0&&Y==1&&B==1||B==0&&Y==1&&R==1||Y==0&&B==1&&R==1)//1个0,2个147 {48 ans = 1;49 }50 else ans = 0; //2个0,1个1,3个051 }52 printf("%I64d\n",ans);53 }54 return 0;55 }

 

转载于:https://www.cnblogs.com/haohaooo/p/4018056.html

你可能感兴趣的文章
在java中使用solr7.2.0 新旧版本创建SolrClient对比
查看>>
网络监控nagios小结
查看>>
详细介绍Linux shell脚本基础学习
查看>>
Heka配置讲解
查看>>
(页面滑动)ionic2-super-tabs插件的使用及注意地方
查看>>
error while loading shared libraries: libmysqlclient.so.15
查看>>
linux上项目报错找不到主机名解决办法
查看>>
分享Android软件:智慧旅行做法
查看>>
linux服务器沦陷为它人发送短信的工具
查看>>
ubuntu如何设置开机启动进入命令行界面
查看>>
windows7系统下文件共享 详细图解教程
查看>>
Java笔试题解(7)
查看>>
SpringMVC使用hibrenate validation进行验证
查看>>
为什么System.out.println(super)不被允许?
查看>>
angular开发中常遇到的坑
查看>>
angularJS
查看>>
微软可穿戴设备新专利公布
查看>>
web应用安全的现状是怎样的
查看>>
QuikNode -Infura高配版
查看>>
JVM学习记录——类加载的过程
查看>>