結果
| 問題 | No.1662 (ox) Alternative | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-02-15 22:06:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 147 ms / 2,000 ms | 
| コード長 | 1,428 bytes | 
| コンパイル時間 | 1,359 ms | 
| コンパイル使用メモリ | 161,728 KB | 
| 実行使用メモリ | 9,912 KB | 
| 最終ジャッジ日時 | 2025-02-15 22:06:40 | 
| 合計ジャッジ時間 | 2,168 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
//Date: 2025-02-15 21:03:45
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define P emplace_back
#define CLEAR(a,v) memset(a,(v),sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
const int N=400000,M=1e9+7;inline int qpow(int x,int y=M-2) {int s=1;for(;y;y>>=1,x=x*x%M) if(y&1) s=s*x%M;return s;}
int fac[N+5],ifac[N+5];inline int C(int n,int m) {return n<m||m<0?0:fac[n]*ifac[m]%M*ifac[n-m]%M;}
inline void add(int &x,int y) {x+=y;x>=M&&(x-=M);}inline void del(int &x,int y) {x-=y;x<0&&(x+=M);}
void init() {fac[0]=1;rep(i,1,N) fac[i]=fac[i-1]*i%M;ifac[N]=qpow(fac[N]);per(i,N,1) ifac[i-1]=ifac[i]*i%M;}
void MAIN() {
    int a=rd(),b=rd(),c=rd(),d=rd();
    if(a!=b) puts("0");else if(a==0&&d==0) puts("1");
    else cout<<C(a+b+c+d,c)*C(a+d-1,d)%M*C(a+b+d,a-1)%M*qpow(a)%M<<endl;
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    SOLVER::init();for(int tt=rd();tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}
            
            
            
        