結果

問題 No.1662 (ox) Alternative
ユーザー ytftytft
提出日時 2021-08-31 10:05:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 8,271 ms
コンパイル使用メモリ 370,216 KB
実行使用メモリ 11,436 KB
最終ジャッジ日時 2023-08-16 13:47:48
合計ジャッジ時間 12,387 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
int main(){
    int T;
    cin>>T;
    for(int j=0;j<T;++j){
        int A,B,C,D;
        cin>>A>>B>>C>>D;
        if(A!=B){
            cout<<0<<endl;
            continue;
        }
        int mod=1e9+7;
        long long a=1,b=A;
        for(int i=1;i<A;++i){
            a=(a*(D+i))%mod;
            b=(b*i)%mod;
            a=(a*(A+D+1+i))%mod;
            b=(b*i)%mod;
        }
        for(int i=1;i<=C;++i){
            a=(a*(A+B+D+i))%mod;
            b=(b*i)%mod;
        }
        int counter=mod-2;
        int ans=1;
        while(counter){
            if(counter%2){
                ans=(ans*b)%mod;
            }
            b=(b*b)%mod;
            counter/=2;
        }
        ans=(ans*a)%mod;
        cout<<ans<<endl;
    }
}
0