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. redis安装,配置

    下载 cd /usr/local/src wget http://download.redis.io/releases/redis-3.0.7.tar.gz     安装 yum install je ...

  2. Application.DoEvents()的使用

    最近做了一个个人数字图书馆管理系统,因为牵扯到电脑文件的扫描,想做一个实时显示当前扫面文件的功能,就类似于360文件扫描时的效果,本来打算用多线程来实现,但是方法太多没有实现,后来在程序中进行控制,由 ...

  3. MooseFs-分布式文件系统系列(一)之了解并安装它

    preface 在上上家公司,曾维护过公司的MFS文件系统,主要用来存储系统日志文件,单纯的把日志当作文件存储,在当时的架构下,MFS就像一个中间站一样,这边程序生成的日志放入MFS,那边日志分析程序 ...

  4. Node-webkit简介

    Node-webkit 概述 Node-webkit 是Github 上一个非常热门的开源项目,它基于著名的浏览器开源项目 Chromium 和服务器端 JavaScript 实现 Node.js 的 ...

  5. 如何用iframe标签以及Javascript制作时钟?

    如何利用iframe标签以及Javascript制作时钟? 如何制作一个时钟呢?效果如下图所示: 这里的时钟会不停的走,但是下面的页面是不会变得,这样就实现了我们想要的效果了.下面我将分为以下几个方面 ...

  6. 每天一个linux命令:route命令

    Linux系统的route命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或 ...

  7. Windows7-32bit系统安装MySQL-5.5.39-win32.msi服务图解

    下载mysql-5.5.39-win32.msi安装文件,双击运行,出现如下界面. mysql安装向导启动,按“Next”继续 在 I accept the terms in the License ...

  8. Centos: 修改 yum安装的mysql路径

    1.使用命令service mysqld stop 停止mysql查看mysql数据库的默认路径:/var/lib/mysql使用cp -afir  /var/lib/mysql/*   /usr/l ...

  9. Log4j、slf4j

    1.Log4j 1.1 Log4j简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出位置)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志 ...

  10. (转)HBase 的原理和设计

    转自:HBase的原理和设计 HBase架构: