\(\text{Solution}\)

这道题想了 \(1\) 个小时多,,看了题解就自闭了。

首先可以把 \(A,B\) 看成一个整体,令它为 \(x\),令 \(C\)\(y\),设 \(sum=x+y\)

  • \(x<=y\)\(y\rightarrow y-x=y-(sum-y)=2y-sum\),这个时候肯定有 \(2y>=sum\),所以相当于乘二取模 \(sum\)

  • \(x>y\)\(y\rightarrow 2y\),这个时候有 \(2y<sum\),所以也相当于乘二取模 \(sum\)

好神奇。

\(\text{Code}\)

#include <cstdio>

#define rep(i,_l,_r) for(signed i=(_l),_end=(_r);i<=_end;++i)
#define fep(i,_l,_r) for(signed i=(_l),_end=(_r);i>=_end;--i)
#define erep(i,u) for(signed i=head[u],v=to[i];i;i=nxt[i],v=to[i])
#define efep(i,u) for(signed i=Head[u],v=to[i];i;i=nxt[i],v=to[i])
#define print(x,y) write(x),putchar(y)

template <class T> inline T read(const T sample) {
    T x=0; int f=1; char s;
    while((s=getchar())>'9'||s<'0') if(s=='-') f=-1;
    while(s>='0'&&s<='9') x=(x<<1)+(x<<3)+(s^48),s=getchar();
    return x*f;
}
template <class T> inline void write(const T x) {
    if(x<0) return (void) (putchar('-'),write(-x));
    if(x>9) write(x/10);
    putchar(x%10^48);
}
template <class T> inline T Max(const T x,const T y) {if(x>y) return x; return y;}
template <class T> inline T Min(const T x,const T y) {if(x<y) return x; return y;}
template <class T> inline T fab(const T x) {return x>0?x:-x;}
template <class T> inline T gcd(const T x,const T y) {return y?gcd(y,x%y):x;}
template <class T> inline T lcm(const T x,const T y) {return x/gcd(x,y)*y;}
template <class T> inline T Swap(T &x,T &y) {x^=y^=x^=y;}

int qkpow(int x,int y,int mod) {
	int r=1;
	while(y) {
		if(y&1) r=1ll*r*x%mod;
		x=1ll*x*x%mod; y>>=1;
	}
	return r;
}

int main() {
	int a,b,c,k;
	for(int t=read(9);t;--t) {
		a=read(9),b=read(9),c=read(9),k=read(9);
		print(1ll*c*qkpow(2,k,a+b+c)%(a+b+c),'\n');
	}
	return 0;
}
posted on 2020-10-23 20:34  Oxide  阅读(138)  评论(0编辑  收藏  举报