提交时间:2022-10-12 16:59:56
运行 ID: 59450
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; inline int read() { int x=0,c=getchar(); while(c<48||c>57)c=getchar(); while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c&15),c=getchar(); return x; } int a,b,c,k,T; int main() { T=read(); while(T--) { a=read();b=read();c=read();k=read(); while(k--) { if(a+b<=c)c-=(a+b),a<<=1,b<<=1; else { int p=min(c>>1,min(a,b)-1); a-=p;b+=p-c;c<<=1; } } printf("%d\n",c); } return 0; }