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. VS2010生成安装包

    项目的第一个版本出来了,要做个安装包,之前没有做过,网上看看贴,写了一个,总结下,根据本项目的需要,没有写的太复杂,可能还不是很完善,仅作参考. 首先在打开 VS2010    >   文件 & ...

  2. 移动端web app自适应布局探索与总结

    要掌握的知识点: iphone6 屏幕尺寸为 375*667 (pt)也就是 网页 全屏显示时候 document.documentElement.clientWidth------可以理解为屏幕越大 ...

  3. Scala高阶函数示例

    object Closure { def function1(n: Int): Int = { val multiplier = (i: Int, m: Int) => i * m multip ...

  4. 【Alpha版本】 第五天 11.11

    一.站立式会议照片: 二.项目燃尽图: 三.项目进展: 成 员 昨天完成任务 今天完成任务 周末+下周一要做任务 问题困难 心得体会 胡泽善 完成了账户信息修改界面 完成管理员的三大界面框架.完成管理 ...

  5. 零散的JavaScript公用方法

    function stopBubble(e) { if (e && e.stopPropagation) {//如果传入了事件对象,那么就是非IE浏览器 e.stopPropagati ...

  6. JS-结合html综合练习js的对象——班级成绩表制作

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>对 ...

  7. Yocto开发笔记之《应用程序架构》(QQ交流群:519230208)

    QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样 ======================================================== Eclip ...

  8. 一台机子上运行使用不同Java版本的多个tomcat

    方法 在tomcat/bin/下创建setenv.sh并写入 export JAVA_HOME=/usr/share/jvm/jdk1..0_91 When you starting tomcat u ...

  9. VBO, VAO, Generic Vertex Attribute

    VBO - 用于存储顶点数据的Buffer Object. VAO - 用于组织VBO的对象. Generic Vertex Attribute - 通用顶点属性. For example, the ...

  10. Red Black Tree in C

    http://web.mit.edu/~emin/www.old/source_code/red_black_tree/index.html