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;
} 
相关文章
|
10月前
|
存储
六道入门树题目带你走入树结构的世界-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
43 0
|
10月前
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
47 0
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
|
人工智能 BI C++
|
算法
聪明的KK【ACM】
聪明的KK【ACM】
108 0
SAP HUM嵌套HU研习之HU03显示内层HU数据
SAP HUM嵌套HU研习之HU03显示内层HU数据
SAP HUM嵌套HU研习之HU03显示内层HU数据
|
人工智能 算法
[UPC] 山东省第九届省赛 Games | dp
题意: 有n堆石子,后手可以在游戏开始之前挪走不超过d堆,然后问后手赢得游戏的方案数量 % 1e9 + 7 思路: 先求出所有数的亦或和 设d p [ i ] [ j ] [ k ] dp[i][j][k]dp[i][j][k]为前 i ii 堆石子挪走 j jj 堆,并且亦或和为 k kk 的方案数 然后进行dp
134 0
2012 ACM/ICPC Asia Regional Tianjin Online-Faulty Odometer
题意:有个特殊汽车的行程表,每逢数字3和8会跳过直接到4和9,给你一个行程表的示数,求汽车实际走的路程。
147 0
|
缓存 架构师 程序员
神物:如何召唤Codethulhu
神物也有些别名,比如“Codethulhu”,“初级开发者的克星”和“质量保证分析员”。