結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー tecchaxntecchaxn
提出日時 2018-03-02 23:50:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 143,992 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-09-04 21:31:18
合計ジャッジ時間 6,032 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
15,120 KB
testcase_01 AC 22 ms
15,040 KB
testcase_02 AC 21 ms
15,092 KB
testcase_03 AC 21 ms
15,088 KB
testcase_04 AC 22 ms
15,204 KB
testcase_05 AC 22 ms
15,120 KB
testcase_06 AC 21 ms
15,076 KB
testcase_07 AC 22 ms
15,036 KB
testcase_08 AC 21 ms
15,256 KB
testcase_09 AC 22 ms
15,040 KB
testcase_10 AC 21 ms
15,100 KB
testcase_11 AC 22 ms
15,092 KB
testcase_12 AC 21 ms
15,020 KB
testcase_13 AC 21 ms
15,076 KB
testcase_14 AC 21 ms
15,080 KB
testcase_15 AC 22 ms
15,040 KB
testcase_16 AC 21 ms
15,128 KB
testcase_17 AC 21 ms
15,080 KB
testcase_18 AC 22 ms
15,132 KB
testcase_19 AC 21 ms
15,084 KB
testcase_20 AC 22 ms
15,072 KB
testcase_21 AC 21 ms
15,132 KB
testcase_22 AC 21 ms
15,016 KB
testcase_23 AC 21 ms
15,020 KB
testcase_24 AC 22 ms
15,084 KB
testcase_25 AC 21 ms
15,088 KB
testcase_26 AC 22 ms
15,092 KB
testcase_27 AC 22 ms
15,092 KB
testcase_28 AC 22 ms
15,124 KB
testcase_29 AC 22 ms
15,112 KB
testcase_30 AC 22 ms
15,100 KB
testcase_31 AC 22 ms
15,084 KB
testcase_32 AC 22 ms
15,200 KB
testcase_33 AC 22 ms
15,216 KB
testcase_34 AC 22 ms
15,036 KB
testcase_35 AC 21 ms
15,076 KB
testcase_36 AC 22 ms
15,308 KB
testcase_37 AC 23 ms
15,072 KB
testcase_38 AC 22 ms
15,324 KB
testcase_39 AC 22 ms
15,084 KB
testcase_40 AC 22 ms
15,128 KB
testcase_41 AC 22 ms
15,084 KB
testcase_42 AC 23 ms
15,072 KB
testcase_43 AC 22 ms
15,020 KB
testcase_44 AC 23 ms
15,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
using namespace std;

//-----------------------------------------------------------------------

const int mod=1e9+7;
const int SIZE=500000;
int fact[SIZE],inv[SIZE],ifact[SIZE];

void make()
{
    inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<SIZE;i++){
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        fact[i]=fact[i-1]*i%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}

int comb(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
}

signed main()
{
    make();
    int N; cin>>N;
    int ans=0;
    int x=0,y=N;
    while(x+y<=2*N){
        int a=comb(x+y-1,x);
        int b=comb(x+y-1,y);
        ans+=(a-b+mod);
        ans%=mod;
        x++,y++;
    }
    cout<<ans<<endl;
 
}
0