結果

問題 No.660 家を通り過ぎないランダムウォーク問題
ユーザー ryoissyryoissy
提出日時 2018-03-02 23:38:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 2,412 ms
コンパイル使用メモリ 143,920 KB
実行使用メモリ 16,068 KB
最終ジャッジ日時 2023-09-04 14:54:48
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
15,816 KB
testcase_01 AC 15 ms
15,740 KB
testcase_02 AC 14 ms
15,952 KB
testcase_03 AC 14 ms
15,860 KB
testcase_04 AC 15 ms
15,812 KB
testcase_05 AC 14 ms
15,812 KB
testcase_06 AC 15 ms
15,800 KB
testcase_07 AC 14 ms
15,784 KB
testcase_08 AC 14 ms
15,792 KB
testcase_09 AC 14 ms
15,860 KB
testcase_10 AC 14 ms
15,944 KB
testcase_11 AC 14 ms
15,756 KB
testcase_12 AC 14 ms
15,876 KB
testcase_13 AC 14 ms
15,844 KB
testcase_14 AC 14 ms
15,768 KB
testcase_15 AC 14 ms
15,736 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 15 ms
15,784 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[15000005];

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<=1400000;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