結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー ryoissyryoissy
提出日時 2018-03-02 23:37:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 144,032 KB
実行使用メモリ 7,796 KB
最終ジャッジ日時 2023-09-04 14:44:00
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,552 KB
testcase_01 AC 6 ms
7,656 KB
testcase_02 AC 6 ms
7,520 KB
testcase_03 AC 6 ms
7,716 KB
testcase_04 AC 6 ms
7,648 KB
testcase_05 AC 6 ms
7,588 KB
testcase_06 AC 6 ms
7,588 KB
testcase_07 AC 6 ms
7,588 KB
testcase_08 AC 6 ms
7,516 KB
testcase_09 AC 6 ms
7,792 KB
testcase_10 AC 6 ms
7,660 KB
testcase_11 AC 6 ms
7,500 KB
testcase_12 AC 6 ms
7,584 KB
testcase_13 AC 6 ms
7,568 KB
testcase_14 AC 6 ms
7,792 KB
testcase_15 AC 6 ms
7,552 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 6 ms
7,504 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


ll fact[5000005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}


int main(void){
	fact[0]=1;
	for(ll i=1;i<=400000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=0;i*2<=n;i++){
		if(i==0)ans++;
		if(i==1){
			ans+=n;
		}
		if(i>=2){
			ll val=fact[n+i*2-1];
			val=val*mod_inverse(fact[n+i],MOD);
			val=(ll)val*n%MOD;
			val=val*mod_inverse(fact[i],MOD);
			ans=(ans+val)%MOD;
		}
	}
	printf("%d\n",ans);
	return 0;
}
0