- 题目链接:https://vjudge.net/contest/231845#problem/J
- 题意:给你三个整数,分别表示三种颜色的球的个数,把球一个一个放到桌子上
- 当放第一个球时,获得0点
- 当把球放到已经放的球的端点时,得到已经放的球的颜色种数的点数
- 当把球放到两个球之间时,获得左边球颜色种数+右边球颜色种数
- 算法:模拟;找规律
- 思路:手动模拟得每次放球所得点数将从0以1为差,递增到 limit1=(R>2?2:1)+(Y>2?2:1)+(B>2?2:1),设 limit2 = (R + Y + B),则 (limit2 - limit1)即 limit1中减少的个数 为最大值的个数。
#include <bits/stdc++.h>
#define pi acos(-1)
#define fastcin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL ll_INF = 0x3f3f3f3f3f3f3f3f;
const int maxn =10000 + 10;
const LL mod = 1e9+7;
LL a[5];
int main()
{
while(cin >> a[0] >> a[1] >> a[2])
{
LL l1=0, l2=0;
LL ans=0;
for(int i=0; i<3; i++){
l2 += a[i];
l1 += a[i]>2?2:a[i];
}
for(LL i=0; i<min(l1, l2); i++){
ans+=i;
}
if(l1<l2) ans+=(l2-l1)*l1;
cout << ans << endl;
}
}