結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー pazzle1230pazzle1230
提出日時 2018-03-04 11:35:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 1,738 ms
コンパイル使用メモリ 164,472 KB
実行使用メモリ 6,876 KB
最終ジャッジ日時 2023-09-21 09:20:02
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,572 KB
testcase_01 AC 5 ms
6,636 KB
testcase_02 AC 6 ms
6,872 KB
testcase_03 AC 6 ms
6,616 KB
testcase_04 AC 6 ms
6,564 KB
testcase_05 AC 6 ms
6,700 KB
testcase_06 AC 6 ms
6,572 KB
testcase_07 AC 5 ms
6,696 KB
testcase_08 AC 6 ms
6,640 KB
testcase_09 AC 6 ms
6,572 KB
testcase_10 AC 6 ms
6,696 KB
testcase_11 AC 6 ms
6,576 KB
testcase_12 AC 6 ms
6,624 KB
testcase_13 AC 6 ms
6,620 KB
testcase_14 AC 6 ms
6,632 KB
testcase_15 AC 6 ms
6,692 KB
testcase_16 AC 6 ms
6,748 KB
testcase_17 AC 6 ms
6,620 KB
testcase_18 AC 6 ms
6,624 KB
testcase_19 AC 6 ms
6,576 KB
testcase_20 AC 6 ms
6,572 KB
testcase_21 AC 6 ms
6,576 KB
testcase_22 AC 6 ms
6,692 KB
testcase_23 AC 6 ms
6,688 KB
testcase_24 AC 6 ms
6,564 KB
testcase_25 AC 6 ms
6,872 KB
testcase_26 AC 6 ms
6,876 KB
testcase_27 AC 6 ms
6,568 KB
testcase_28 AC 6 ms
6,620 KB
testcase_29 AC 8 ms
6,688 KB
testcase_30 AC 8 ms
6,572 KB
testcase_31 AC 8 ms
6,576 KB
testcase_32 AC 10 ms
6,616 KB
testcase_33 AC 11 ms
6,688 KB
testcase_34 AC 11 ms
6,576 KB
testcase_35 AC 22 ms
6,560 KB
testcase_36 AC 23 ms
6,640 KB
testcase_37 AC 23 ms
6,700 KB
testcase_38 AC 52 ms
6,632 KB
testcase_39 AC 56 ms
6,844 KB
testcase_40 AC 56 ms
6,616 KB
testcase_41 AC 89 ms
6,688 KB
testcase_42 AC 89 ms
6,636 KB
testcase_43 AC 103 ms
6,572 KB
testcase_44 AC 114 ms
6,632 KB
権限があれば一括ダウンロードができます

ソースコード

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[412345] = {};
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, 412344){
		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