結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー どららどらら
提出日時 2018-03-26 00:58:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,148 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 165,876 KB
実行使用メモリ 6,800 KB
最終ジャッジ日時 2023-09-07 12:21:05
合計ジャッジ時間 9,824 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
6,476 KB
testcase_01 AC 119 ms
6,668 KB
testcase_02 AC 117 ms
6,484 KB
testcase_03 AC 122 ms
6,472 KB
testcase_04 AC 118 ms
6,480 KB
testcase_05 AC 118 ms
6,680 KB
testcase_06 AC 116 ms
6,524 KB
testcase_07 AC 117 ms
6,476 KB
testcase_08 AC 117 ms
6,476 KB
testcase_09 AC 117 ms
6,452 KB
testcase_10 AC 119 ms
6,536 KB
testcase_11 AC 117 ms
6,464 KB
testcase_12 AC 116 ms
6,460 KB
testcase_13 AC 113 ms
6,472 KB
testcase_14 AC 114 ms
6,524 KB
testcase_15 AC 116 ms
6,476 KB
testcase_16 AC 115 ms
6,576 KB
testcase_17 AC 118 ms
6,508 KB
testcase_18 AC 119 ms
6,532 KB
testcase_19 AC 117 ms
6,480 KB
testcase_20 AC 115 ms
6,684 KB
testcase_21 AC 114 ms
6,516 KB
testcase_22 AC 115 ms
6,572 KB
testcase_23 AC 115 ms
6,576 KB
testcase_24 AC 118 ms
6,532 KB
testcase_25 AC 115 ms
6,684 KB
testcase_26 AC 117 ms
6,536 KB
testcase_27 AC 121 ms
6,544 KB
testcase_28 AC 117 ms
6,532 KB
testcase_29 AC 122 ms
6,476 KB
testcase_30 AC 116 ms
6,516 KB
testcase_31 AC 121 ms
6,476 KB
testcase_32 AC 116 ms
6,484 KB
testcase_33 AC 115 ms
6,472 KB
testcase_34 AC 122 ms
6,480 KB
testcase_35 AC 115 ms
6,800 KB
testcase_36 AC 117 ms
6,476 KB
testcase_37 AC 114 ms
6,536 KB
testcase_38 AC 117 ms
6,516 KB
testcase_39 AC 115 ms
6,476 KB
testcase_40 AC 114 ms
6,600 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define MX 200005

ll fact[MX];
ll invfact[MX];

ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}
ll mod_comb(ll n, ll k){
  if(n<0 || k<0 || n<k) return 0;
  return (((fact[n] * invfact[k]) % MOD) * invfact[n-k]) % MOD;
}
void comb_init(){
  fact[0] = fact[1] = 1;
  for(ll i=2; i<MX; i++) fact[i] = (fact[i-1] * i) % MOD;
  invfact[0] = invfact[1] = 1;
  for(ll i=2; i<MX; i++) invfact[i] = mod_pow(fact[i], MOD-2, MOD);
}
int main(){
  comb_init();
  
  int N;
  cin >> N;

  ll ret = 1;
  REP(i,1,N/2+1){
    ll h = i;
    ll w = N-1+i;
    ll tmp1 = mod_comb(h+w, w);
    ll tmp2 = mod_comb(h-1+w+1, w+1);
    ll ans = (tmp1 - tmp2 + MOD)%MOD;
    ret += ans;
    ret %= MOD;
  }

  cout << ret << endl;
  
  return 0;
}
0