提交时间:2022-10-12 16:59:57
运行 ID: 59451
#include<bits/stdc++.h> using namespace std; typedef long long ll; int t; ll a,b,c,k; ll fastpow(ll a,ll k,ll mod) { ll base=1; for(; k; k>>=1,a=a*a%mod)if(k&1)base=base*a%mod; return base; } int main() { scanf("%d",&t); while(t--) { scanf("%lld%lld%lld%lld",&a,&b,&c,&k); printf("%lld\n",fastpow(2,k,a+b+c)*c%(a+b+c)); } return 0; }