• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

2013 Asia Nanjing Regional Contest J

Ball

Time Limit: 2000/1000 MS (Java/Others)    

Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 254    Accepted Submission(s): 110

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: � For the first ball being placed on the table, he scores 0 point. � 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. � 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
 
Source
2013ACM/ICPC亚洲区南京站现场赛——题目重现
 
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  4812 4810 4809 4808 4807 
 1 #include <cstdio>
 2 #include <vector>
 3 #include <cmath>
 4 #include <queue>
 5 #include <cstring>
 6 #include <iostream>
 7 #include <algorithm>
 8 using namespace std;
 9 #define INF 100000000
10 #define mod 1000000007
11 #define ll long long
12 #define maxn 1005
13 #define pi acos(-1.0)
14 ll n, m, k, d, x, y, ans, t, a, b;
15 int main(){
16     while (~scanf("%I64d%I64d%I64d", &n, &m, &k)){
17         ans = 0;
18         t = min(2LL, n) + min(2LL, m) + min(2LL, k);
19         for (int i = 0; i < t; i++)ans += i;
20         ans += (n + m + k - t)*t;
21         printf("%I64d\n", ans);
22     }
23     return 0;
24 }
View Code
posted @ 2013-12-20 18:24  HaibaraAi  阅读(115)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3