Description:
In the last semester, Rikka joined the badminton club.
There are nn students in the badminton club, some of them have rackets, and some of them have balls. Formally, there are aa students have neither rackets nor balls, bb students have only rackets, cc students have only balls, and ddstudents have both rackets and balls. (a+b+c+d=n)(a+b+c+d=n)
This week, the club is going to organize students to play badminton. Each student can choose to take part in or not freely. So there are 2n2n possible registration status.
To play badminton, there must be at least two students who have rackets and at least one students who have balls. So if there aren't enough balls or rackets, the activity will fail.
Now, Rikka wants to calculate the number of the status among all 2n2n possible registration status which will make the activity fail.Input
The first line contains a single number t(1≤t≤103)t(1≤t≤103), the number of testcases.
For each testcase, the first line contains four integers a,b,c,d(0≤a,b,c,d≤107,a+b+c+d≥1)a,b,c,d(0≤a,b,c,d≤107,a+b+c+d≥1).Output
For each testcase, output a single line with a single integer, the answer modulo 998244353998244353.
Sample Input
3 1 1 1 1 2 2 2 2 3 4 5 6Sample Output
12 84 2904一群人打羽毛球,a个人啥都没有,b个人只有一个拍,c个人只有一个球,d个人有一个拍一个球,只有同时有两个拍一个球才能一起打,问多少种情况不能一起打
有三种情况不能一起打,
1.没有球,
2.没有拍,
3.只有一个拍
A:无拍 2^a*2^a;
B:只有一个拍: 2^a*2^c*b+2^a*2^c*d
C:无球: 2^a*2^b
AB:相互矛盾 0
AC:无拍无球 2^a
BC: 一个拍无球 2^a*b
方法总数:A+B+C-AB-AC-BC
AC代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<iomanip>
#include<math.h>
const int INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
typedef double ld;
const int N=1e6+10;
const int MOD=998244353;
ll a,b,c,d;
ll mi(ll x,ll y)
{
if(!y)
return 1;
ll temp=mi(x,y/2);
temp*=temp;
temp%=MOD;
if(y&1)
{
temp*=x;
temp%=MOD;
}
return temp;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
ll ans=mi(2,a+c);
ans=((b+d+1)*ans)%MOD;
ans=(ans+mi(2,a+b));
ans=(ans-(mi(2,a)*(b+1))%MOD)%MOD;
ans=(ans+MOD)%MOD;
printf("%lld\n",ans);
}
return 0;
}