J - Ball

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define M(a,b) memset(a,b,sizeof(a))
#include<map>
using namespace std; long long R,Y,B; int main()
{
while(scanf("%I64d%I64d%I64d",&R,&Y,&B)==)
{
long long ans = ;
if(R>=&&Y>=&&B>=) //全大于1
ans = (R+Y+B-)*+;
else
{
if(R==&&Y>&&B>||Y==&&R>&&B>||B==&&Y>&&R>) //一个1其余大于1
{
ans = (R+Y+B-)*+;
}
else if(R==&&Y==&&B>||B==&&Y==&&R>||R==&&B==&&Y>) //两个1一个大于1
{
ans = (R+Y+B-)*+;
}
else if(R==&&Y==&&B==) //3个1
{
ans = ;
}
else if(R==&&Y>&&B>||B==&&Y>&&R>||Y==&&B>&&R>) //1个0
{
ans = (R+Y+B-)*+;
}
else if(R==&&Y==&&B>||B==&&Y==&&R>||R==&&B==&&Y>)//2个0
{
ans = (R+B+Y-)*+;
}
else if(R==&&Y==&&B>||R==&&Y==&&B>||B==&&Y==&&R>||B==&&Y==&&R>||R==&&B==&&Y>||B==&&R==&&Y>) //1个0,1个1
{
ans = (R+B+Y-)*+;
}
else if(R==&&Y==&&B==||B==&&Y==&&R==||Y==&&B==&&R==)//1个0,2个1
{
ans = ;
}
else ans = ; //2个0,1个1,3个0
}
printf("%I64d\n",ans);
}
return ;
}

2013nanjingJ的更多相关文章

随机推荐

  1. 找女神要QQ号码

    引言 我们组来了个美女程序员,我心里窃喜,哈哈这下机会来了.我在想怎么下手呢?好吧,还是从QQ号码开始,找到女神要到QQ号,哈哈,我真是个天才~~~ 是这样子滴 想法是美好的,现实是残酷的,找女神要Q ...

  2. Beta版本——第三次冲刺博客

    我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...

  3. 生活中的MVC模式,一个吃货的理解。

    以下是生活中对于MVC模式的领悟,虽然可笑,轻喷. 2015年 8月 26日 M  => Model       模型 我认为叫做模具更好的理解.批量加工生产具有相同特征的东西.        ...

  4. Spring配置文件详解 – applicationContext.xml文件路径

    Spring配置文件详解 – applicationContext.xml文件路径 Java编程                 spring的配置文件applicationContext.xml的默 ...

  5. B1/B2签证拒签

    http://www.mcdvisa.com/html/News/USA_visa_news/201529/152917GE.html

  6. Marshal

    https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx http://tomosoft.jp/design/?p=4647 ht ...

  7. 几个有用的jQuery代码片段

    1.检测Internet Explorer版本 $(document).ready(function() { if (navigator.userAgent.match(/msie/i) ){ ale ...

  8. jquery 停止animate动画,并且回复最初状态

    // 热门推荐悬浮效果 $("#recom_con li img").mouseenter(function(){ $(this).stop(true, true); $w = p ...

  9. 扩展服务 修改新增Service的默认主题

    问题描述:想要在F:\PHPnow-1.5.6\htdocs\yt\Yourphp\Tpl\      目录下新增一个Service\Default(A)   和Service\new(B) 两个主题 ...

  10. yourphp搜索代码

    HTML代码 <form method="GET" action="index.php?"> //指向地址 <input type=" ...