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. centos安装altas

    centos6.6 atlas2.2.1 atlas项目 https://github.com/Qihoo360/Atlas/releases yum -y install gcc make ncur ...

  2. C#如何在子窗体获取父窗体的实例

    在子窗体可以使用this.Owner来获取父窗体的实例

  3. Solution: Win 10 和 Ubuntu 16.04 LTS双系统, Win 10 不能从grub启动

    今年2月份在一台装了Windows的机器上装了Unbuntu 14.04 LTS (双系统, dual-boot, 现已升级到 16.04 LTS). 然而开机时要从grub启动 Windows (选 ...

  4. POJ 2533 Longest Ordered Subsequence(最长上升子序列(NlogN)

    传送门 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subseque ...

  5. iOS - Xcode7.3插件实效问题解决方法

    以往Xcode升级插件实效.1.关闭xcode 2.终端获取uid 3.文件中info.plist手动添加uid,现在不用了.在网上找的,特地记录一下,尤其是插件太多,不会麻烦了. 详细操作步骤: 关 ...

  6. Hibernate_增删改

    package com.etc.test;import java.util.List;import org.hibernate.Session;import org.hibernate.Session ...

  7. IEquatable 的Equals 代替 object 的Equals

    struct Point2 : IEquatable<Point2> { public int X { get; set; } public int Y { get; set; } pub ...

  8. 记一次mysql故障恢复

    事情要从俩月前的一个坑说起,一台新的测试服务器,新项目一元夺宝用的. 配置aws上的一台云主机,系统盘8G,一块300G的云硬盘. 拿到机器后,另一运维小哥安装php,nginx,mysql等软件. ...

  9. GLSL Interface Block参考

    http://www.opengl.org/wiki/Interface_Block_(GLSL) http://stackoverflow.com/questions/9916103/opengl- ...

  10. JNDI全面总结

    JNDI全面总结原理: 在DataSource中事先建立多个数据库连接,保存在数据库连接池中.当程序访问数据库时,只用从连接池中取空闲状态的数据库连接即可,访问结束,销毁资源,数据库连接重新回到连接池 ...