#include <bits/stdc++.h>
#define int long long
using namespace std;
int T,a,b,c,d;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
int ans=0,xa=0,xb=0;
cin>>a>>b>>c>>d;
xa=a;xb=a;
ans=a;
while((xa!=0||xb!=0)&&(b!=0||c!=0)){
if(xa>0){
ans++;
b--;
xa++;
xb--;
}
else{
ans++;
c--;
xa--;
xb++;
}
}
if(xa==0&&xb==0) cout<<ans<<"\n";
else cout<<ans+min(xa,xb)<<"\n";
}
}
如果xa和b一样导致没法用b就会陷入死循环(xa-=0 & b-=0)
1 个赞