题目链接:

Ball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2149    Accepted Submission(s): 897

Problem 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 109.
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
题意:
给出三种球的个数,然后再求题目要求的那个最大值;
思路:
分情况讨论啦,比如现在现在三种球的个数都大于2,那么在放球的话就可以最大得到6的分数了,然后其他的情况也是这样啦;
AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int n,m,k;
int main()
{while(scanf("%d%d%d",&n,&m,&k)!=EOF){if(n>=2&&m>=2&&k>=2){LL ans=n-2+m-2+k-2;printf("%lld\n",ans*6+15);}else {int a[4];a[0]=n,a[1]=m,a[2]=k;sort(a,a+3);int num=0;for(int i=0;i<3;i++)if(a[i]==0)num++;if(num==3)printf("0\n");else if(num==2){if(a[2]==1)printf("0\n");else printf("%d\n",a[2]*2-3);}else if(num==1){if(a[2]==1)printf("1\n");else {if(a[1]==1){if(a[2]==1)printf("1\n");else {LL ans=a[2]-2;printf("%lld\n",3*ans+3);}}else {LL ans=a[1]-2+a[2]-2;printf("%lld\n",ans*4+6);}}}else {if(a[2]==1)printf("3\n");else {if(a[1]==1){LL ans=a[2]-2;printf("%lld\n",6+ans*4);}else {LL ans=a[1]-2+a[2]-2;printf("%lld\n",5*ans+10);}}}}}return 0;
}

  

转载于:https://www.cnblogs.com/zhangchengc919/p/5926647.html

hdu-4811 Ball相关推荐

  1. HDU 5821 Ball

    记录一下每个位置最终到达的位置.然后每次操作排序. #pragma comment(linker, "/STACK:1024000000,1024000000") #include ...

  2. python接口自动化用例管理_python接口自动化测试(六)-unittest-单个用例管理

    前面五节主要介绍了环境搭建和requests库的使用,可以使用这些进行接口请求的发送.但是如何管理接口案例?返回结果如何自动校验?这些内容光靠上面五节是不行的,因此从本节开始我们引入python单元测 ...

  3. 2013_nanjing_onsite

    4802 GPA 签到题目. 4803 Poor Warehouse Keeper 优先考虑增长较快的上键,贪心即可. 4804 Campus Design 插头dp,加一维表示1*1的个数. 480 ...

  4. 杭电OJ分类题目(1)

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(1) HDU Introduction HDU ...

  5. HDU 2277 Change the ball

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2277 Change the ball Time Limit: 2000/1000 MS (Java/O ...

  6. hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  7. HDU 1556 Color the ball (数状数组)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  8. hdu 4605 Magic Ball Game (在线主席树/离线树状数组)

    版权声明:本文为博主原创文章,未经博主允许不得转载. hdu 4605 题意: 有一颗树,根节点为1,每一个节点要么有两个子节点,要么没有,每个节点都有一个权值wi .然后,有一个球,附带值x . 球 ...

  9. hdu 1556 Color the ball

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  10. 【HDU - 1943】Ball bearings(几何问题)

    题干: The Swedish company SKF makes ball bearings. As explained by Britannica Online, a ball bearing i ...

最新文章

  1. U^2-Net跨界肖像画,完美复刻人物细节,GitHub标星2.5K+
  2. Application Desktop Toolbars 桌面工具栏
  3. Rider EAP17带来了许多改进但缺乏.NET Core调试功能
  4. android 重装sdk或者系统的时模拟器出现can open ****
  5. 【知乎】怎么成为一个优秀的程序员,而不是一个优秀的码农?
  6. [css] box-sizing的宽度包含了哪些?
  7. 关于部分应用无法向POJ提交代码的解决方案
  8. 开课吧python小课学了有用吗-考研人注意了,停下手头的活,再忙也要看一下这个!...
  9. vb中如何连接mysql_vb怎么连接数据库
  10. python 分词器比较
  11. python中merge函数_Python Merge函数原理及用法解析
  12. 后台管理系统 - 权限设计
  13. 视频和视频帧:视频和帧基础知识整理
  14. 【Alpha版本】项目测试
  15. win10 uwp 应用转后台清理内存
  16. 为何水在地球上几亿年都不过期,装进瓶子却很快过期科学家解惑
  17. 【视频开发】【CUDA开发】ffmpeg nvenc编码
  18. php 标准规范,PHP PSR标准规范
  19. EV2200 使用教程
  20. vmei-day04-Jcenter方式集成极光推送

热门文章

  1. pip安装python包出错:ctype = ctype.encode(default_encoding) # omit in 3.x!
  2. 美团点评效果广告实验配置平台的设计与实现
  3. 5.MYSQL存储过程的管理
  4. 【Scratch】青少年蓝桥杯_每日一题_5.07_猜数字
  5. The import javax.servlet cannot be resolved
  6. linux 关闭网络防火墙设置方法,CentOS Linux防火墙配置及关闭方法
  7. ddnspod php 脚本_使用DNSPOD的域名解析实现DDNS域名动态的脚本
  8. php实现微信清粉功能,PHP实现微信提现功能
  9. 计算机微格教学心得体会,微格教学心得体会
  10. 2022年改变数据中心行业的八大趋势