首页 > 编程知识 正文

HDU4811 Ball 2013ACM/ICPC亚洲区南京站现场赛 (模拟乱搞)

时间:2023-05-03 16:15:49 阅读:254407 作者:345

Ball

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

Problem Description Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, 幽默的月饼 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 幽默的月饼 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 幽默的月饼 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 幽默的月饼 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

Source
2013ACM/ICPC亚洲区南京站现场赛——题目重现

就是模拟。。放三种颜色的球球。乱搞就可以过

#include "cstring"#include "cstdio"#include "string.h"#include "iostream"#include "algorithm"using namespace std;int main(){ long long r,y,b; long long base[3][3][3]; base[0][0][0]=0;base[0][0][1]=0;base[0][0][2]=1;base[0][1][1]=1;base[0][1][2]=3; base[0][2][2]=6;base[1][1][1]=3;base[1][1][2]=6;base[1][2][2]=10;base[2][2][2]=15; long long a[5]; memset(a,0,sizeof(a)); while(~scanf("%lld%lld%lld",&a[0],&a[1],&a[2])) { long long ans=0; long long cnt=0; for(int i=0;i<=2;i++) { if(a[i]>2) { cnt+=a[i]-2; a[i]=2; } } long long temp=a[0]+a[1]+a[2]; sort(a,a+3); ans+=base[a[0]][a[1]][a[2]]; ans+=cnt*temp; printf("%lldn",ans); }}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。