题目链接:https://codeforces.com/contest/1263
把最小值分摊给其他两个,然后剩下的再加上最小值
#include<bits/stdc++.h>
#define x first
#define y second
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int mx = 1e6 + 10;
int n,m;
int main()
{
int t;scanf("%d",&t);
while (t--) {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if (a > b) swap(a,b);
if (a > c) swap(a,c);
if (b > c) swap(b,c);
int dif = c - b;
int ans = a;
if (dif >= a) {
printf("%d\n",b+a);
} else {
a -= dif;
printf("%d\n",ans+b-(a+1)/2);
}
}
return 0;
}
易知一个字符串变一次可以有9+9+9+9==36种变法,所以肯定存在一种变法使得跟其他字符串都不一样。然后就暴力一下就ok了
#include<bits/stdc++.h>
#define x first
#define y second
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int mx = 1e6 + 10;
int n,m;
multiset <string> mst;
int change(string& ss) {
if (mst.count(ss) == 1) {
return 0;
}
mst.erase(mst.find(ss));
for (int i=0;i<4;i++) {
for (int j=0;j<10;j++) {
if (ss[i]==j+