题解(有点暴力版)
2025-08-11 22:48:29
发布于:浙江
5阅读
0回复
0点赞
题意:有三种拆分方式 aa(a+a),wa(w+a),ac(a+c)
ok 写上公式tm5分
那我就枚举wa有多少个,正好时间复杂度不会爆
没什么好讲得啦,就上代码(这题我提交了25次)
# include <bits/stdc++.h>
typedef unsigned long long ull;
#define endl '\n'
#define int long long
using namespace std ;
void mle(){
string s = "a";
while(1) s += s;
}
signed main ( )
{
int t;
cin>>t;
while(t--){
int x = 0,y = 0,z = 0;
scanf("%lld %lld %lld",&x,&y,&z);
int res = -1;
int maxi = min(x,z),mini = 0;
for(int wa = 0;wa<=maxi;wa++){
int a = x-wa;
int ac = min(a,y);
int aa = (a-ac)/2;
int tot = wa+ac+aa;
if(tot>res||(tot==res&&wa<mini)){
res = tot;
mini = wa;
}
}
printf("%d %d\n",res,mini);
}
return 0;
}
这里空空如也
有帮助,赞一个