結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー pazzle1230pazzle1230
提出日時 2018-03-04 11:34:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,220 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 165,680 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-09-21 09:18:54
合計ジャッジ時間 5,115 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,000 KB
testcase_01 AC 4 ms
5,000 KB
testcase_02 AC 4 ms
4,996 KB
testcase_03 AC 4 ms
4,996 KB
testcase_04 AC 4 ms
5,016 KB
testcase_05 AC 4 ms
5,020 KB
testcase_06 AC 4 ms
5,012 KB
testcase_07 AC 4 ms
5,140 KB
testcase_08 AC 4 ms
5,008 KB
testcase_09 AC 3 ms
5,000 KB
testcase_10 AC 4 ms
5,064 KB
testcase_11 AC 4 ms
5,012 KB
testcase_12 AC 4 ms
5,004 KB
testcase_13 AC 4 ms
5,000 KB
testcase_14 AC 4 ms
5,064 KB
testcase_15 AC 4 ms
5,188 KB
testcase_16 AC 3 ms
4,996 KB
testcase_17 AC 4 ms
5,072 KB
testcase_18 AC 4 ms
5,016 KB
testcase_19 AC 4 ms
5,076 KB
testcase_20 AC 4 ms
5,008 KB
testcase_21 AC 4 ms
5,064 KB
testcase_22 AC 4 ms
5,124 KB
testcase_23 AC 4 ms
5,012 KB
testcase_24 AC 4 ms
5,128 KB
testcase_25 AC 4 ms
4,996 KB
testcase_26 AC 4 ms
5,140 KB
testcase_27 AC 5 ms
5,004 KB
testcase_28 AC 5 ms
5,076 KB
testcase_29 AC 6 ms
5,008 KB
testcase_30 AC 6 ms
4,996 KB
testcase_31 AC 6 ms
5,068 KB
testcase_32 AC 9 ms
5,172 KB
testcase_33 AC 9 ms
5,064 KB
testcase_34 AC 10 ms
5,016 KB
testcase_35 AC 21 ms
5,068 KB
testcase_36 AC 21 ms
5,000 KB
testcase_37 AC 21 ms
5,000 KB
testcase_38 AC 50 ms
5,020 KB
testcase_39 AC 52 ms
5,176 KB
testcase_40 AC 54 ms
5,140 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#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(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 N;
int64 fact[212345] = {};
const int64 mod = 1e9+7;

int64 mpow(int64 a, int64 b){
	if(b == 0) return 1;
	if(b%2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

int64 comb(int64 a, int64 b){
	if(a < 0 || b < 0) return 0;
	return fact[a]*mpow(fact[b], mod-2)%mod*mpow(fact[a-b], mod-2)%mod;
}

int main(void){
	cin >> N;

	fact[0] = 1;
	REP(i, 212344){
		fact[i+1] = (fact[i]*(i+1))%mod;
	}

	int64 x = N/2;
	int64 res = 0;
	int64 now = 0;

	for(int32 i = 0;i < N/2+1;i++){
		res = (res+comb(N+2*i-1, i)-comb(N+2*i-1, i-1)+mod)%mod;
	}
	cout << res << endl;

}
0