提交时间:2024-01-02 13:38:47
运行 ID: 118918
#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; }