日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdu-4811 Ball

發布時間:2025/3/21 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdu-4811 Ball 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。