結果

問題 No.1044 正直者大学
ユーザー cureskolcureskol
提出日時 2019-11-29 22:02:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,258 bytes
コンパイル時間 8,117 ms
コンパイル使用メモリ 296,164 KB
実行使用メモリ 81,792 KB
最終ジャッジ日時 2024-05-02 14:51:22
合計ジャッジ時間 23,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;
#define int long long
const int MOD=1e9+7;
const int MIN_N=1,MAX_N=100000;
const int MIN_K=0,MAX_K=200000;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){// limit is 5e6 /// write pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}
int n,m,k;

int f(int a){
  if(a&1)return 0;
  a>>=1;
  int res=nCk(n,a)*nCk(m,a)%MOD;
  res*=Factorial[n-1]*Factorial[m-1]%MOD;res%=MOD;
  return res*a%MOD;
}

signed main(){
  registerValidation();
  int a=inf.readLong(MIN_N,MAX_N);
  inf.readSpace();
  m=inf.readLong(MIN_N,MAX_N);
  inf.readSpace();
  k=inf.readLong(MIN_K,MAX_K);
  inf.readEoln();
  ensuref(k<=n+m,"k<=n+m");
  int ans=0;
  for(int i=0;i<=n+m-k;i++)ans+=f(i),ans%=MOD;
  cout<<ans<<endl;
  inf.readEof();
}
0