結果
| 問題 |
No.660 家を通り過ぎないランダムウォーク問題
|
| ユーザー |
tecchaxn
|
| 提出日時 | 2018-03-02 23:50:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 924 bytes |
| コンパイル時間 | 1,226 ms |
| コンパイル使用メモリ | 158,964 KB |
| 実行使用メモリ | 15,224 KB |
| 最終ジャッジ日時 | 2024-06-22 19:00:37 |
| 合計ジャッジ時間 | 3,338 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 |
ソースコード
#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;
}
tecchaxn