推一波式子就完了,就是三维的情况拓展到四维
注意a,b,c,d中有1的情况
Code:
#include<bits/stdc++.h>
#define mod 2148473648
#define ll long long
using namespace std;
inline ll read(){
ll res=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-f;ch=getchar();}
while(isdigit(ch)) {res=(res<<1)+(res<<3)+(ch^48);ch=getchar();}
return res*f;
}
ll ans[10],in[10];
int main(){
int t=read();
while(t--){
memset(ans,0,sizeof(ans));
for(int i=1;i<=4;i++) in[i]=read();
sort(in+1,in+5);
ll a=in[1],b=in[2],c=in[3],d=in[4];
if(d==1){ans[8]=1;}
else if(c==1){ans[6]=d-2;ans[7]=2;}
else if(b==1){ans[6]=4;ans[4]=(c-2)*(d-2)%mod;ans[5]=2*(c-2+d-2)%mod;}
else if(a==1){ans[5]=8;ans[2]=(b-2)*(c-2)*(d-2)%mod;ans[3]=2*((b-2)*(c-2)+(b-2)*(d-2)+(c-2)*(d-2))%mod;ans[4]=4*(b-2+c-2+d-2)%mod;}
else{
ans[4]=16;
ans[3]=8*(a-2+b-2+c-2+d-2)%mod;
ans[2]=4*((a-2)*(b-2)+(a-2)*(c-2)+(a-2)*(d-2)+(b-2)*(c-2)+(b-2)*(d-2)+(c-2)*(d-2))%mod;
ans[1]=2*((a-2)*(b-2)*(c-2)+(a-2)*(b-2)*(d-2)+(a-2)*(c-2)*(d-2)+(b-2)*(c-2)*(d-2))%mod;
ans[0]=(a-2)*(b-2)%mod*(c-2)%mod*(d-2)%mod;
}
for(int i=0;i<=8;i++) cout<<ans[i]<<" ";
cout<<"\n";
}
return 0;
}