ZZULIOJ----2618: ACM-ICPC亚洲区域赛ZZUL

简介: ZZULIOJ----2618: ACM-ICPC亚洲区域赛ZZUL

题意描述:

玩了这么多游戏,V决定还是去做几道ACM题练练手,于是翻到了一道201X年ACM/ICPC亚洲区域赛某站的现场赛签到试题,但是由于多年不刷题,已经忘了怎么做了

作为将来的ACM校队扛把子的你,请帮助他解决一下吧。

现场赛题目如下:

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?

hint:对于志在区域赛的acmer们,数学思维和英语读题能力是必不可少的 : )

hint again: 感谢husy(胡胜勇)对本次周赛试题的数据测试及标程提供

输入:

多实例

输入T,表示共有T组数据(T=100)

每组数据包含三个整数R,Y,B (0<= R,Y,B <=10000)

输出:

对于每组输入,输出最高得分

样例输入:

3
2 2 2
3 3 3
4 4 4

样例输出:

15
33
51

解题思路:这个题就是一个模拟的过程,因为题上说总和分最大也就是每一次放球都要保证得分最大。

1、当只有一种颜色球的时候,最后得分每一次最高为2;

2、当只有两种颜色的球和其中一种颜色球只有一个时候,最后每一次得到的最高分为3;

3、当只有两种颜色的球的时候 ,最后每一次得分最高为4;

4、当其中两种颜色的球只有一个的时候,最后每次最高得分为4;

5、当一种颜色球为1个另一个颜色球为2的时候,最后每次最高得分为5;

6、当一种颜色球为1,其余都大于2的时候,最后每次得分最高为5;

7、当三种颜色球都大于2的时候,最后每次得分最高为6;

程序代码:

#include<stdio.h>
int main()
{
    int i,n,m,j,k,T;
    long long a,b,c,sum;
    scanf("%d",&T);
    while(T--)
    {
        sum=0;
        scanf("%lld%lld%lld",&a,&b,&c);
        n=a+b+c;
        if(n==0||n==1)
            sum=0;
        if(n>=2)
            sum+=1;
        if(n>=3)
            sum+=2;
        if((a==0&&b==0)||(a==0&&c==0)||(c==0&&b==0))
        {
          if(n>=4)
            sum+=2*(n-3);
        }
        else if((a==0&&b==1)||(a==0&&c==1)||(c==0&&b==1)||((c==0&&a==1)||(b==0&&a==1)||(b==0&&c==1)))
        {
            if(n>=3)
                sum+=3*(n-3);
        } 
        else if((a==0&&b>1)||(a==0&&c>1)||(c==0&&b>1)||((c==0&&a>1)||(b==0&&a>1)||(b==0&&c>1)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4*(n-4);
        }
        else if((a==1&&b==1)||(a==1&&c==1)||(c==1&&b==1)||((c==1&&a==1)||(b==1&&a==1)||(b==1&&c==1)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4*(n-4);
        }
        else if((a==1&&b==2)||(a==1&&c==2)||(c==1&&b==2)||((c==1&&a==2)||(b==1&&a==2)||(b==1&&c==2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5*(n-5);
        }
        else if((a==1&&b>2)||(a==1&&c>2)||(c==1&&b>2)||((c==1&&a>2)||(b==1&&a>2)||(b==1&&c>2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5*(n-5);
        }
        else if((a>=2&&b>=2&&c>=2)||(a>=2&&c>=2&&b>=2)||(a>=2&&c>=2&&b>=2)||((b>=2&&c>=2&&a>=2)||(c>=2&&b>=2&&a>=2)||(a>=2&&b>=2&&c>=2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5;
            if(n>=7)
                sum+=6*(n-6);
        }
        printf("%lld\n",sum);
    }
    return 0;
} 
相关文章
|
4月前
|
存储
六道入门树题目带你走入树结构的世界-liu-dao-ru-men-shu-ti-mu-dai-ni-zou-ru-shu-jie-gou-de-shi-jie
六道入门树题目带你走入树结构的世界-liu-dao-ru-men-shu-ti-mu-dai-ni-zou-ru-shu-jie-gou-de-shi-jie
19 0
|
4月前
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
27 0
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
84 0
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
PTA 7-5 实验室使用排期 (25 分)
假设规定任何一个时间点上,实验室内最多只能有 1 个人,且每个人都必须提前申请实验室的使用,只有申请被批准后才能进入。
85 0
|
边缘计算 Cloud Native 5G
OpenInfra Days China 2022 分论坛议程全览
OpenInfra Days China 2022 分论坛议程全览
133 0
OpenInfra Days China 2022 分论坛议程全览
PAT甲级 1005. Spell It Right(20分)
PAT甲级 1005. Spell It Right(20分)
48 0
|
Python
ZZULIOJ-1019,公园门票(Python)
ZZULIOJ-1019,公园门票(Python)
|
Python
ZZULIOJ-1074,百钱买百鸡(Python)
ZZULIOJ-1074,百钱买百鸡(Python)