結果

問題 No.569 3 x N グリッドのパスの数
ユーザー HIR180HIR180
提出日時 2017-09-08 23:55:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,995 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 145,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 08:41:18
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,384 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 2 ms
4,384 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,384 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
/*vector<P>vec[100005];
int cnt = 0;
#define mod 1000000007
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n; n%=mod;
	ll x[15];
	x[0]=1; for(int i=1;i<15;i++)x[i]=x[i-1]*1LL*n%mod;
	
	ll ans = x[1]*(x[10]-15LL*x[8]+6LL*x[7]+50LL*x[6]-26LL*x[5]-39LL*x[4]+36LL*x[3]-4LL*x[2]-4LL*x[1]+1LL)%mod;
	ll ans2 = (x[6]+2LL*x[5]-9LL*x[4]-5LL*x[3]+15LL*x[2]-8LL*x[1]+1LL)%mod;
	ans2 *= (x[6]+2LL*x[5]-7LL*x[4]-3LL*x[3]+7LL*x[2]-4LL*x[1]+1LL)%mod; ans2%=mod;
	cout<<(ans*modpow(ans2,mod-2)%mod+mod)%mod<<endl;
}*/
int main(){
	ll a[12]={1, 8, 38, 184, 976, 5382, 29739, 163496, 896476, 4913258, 26932712, 147657866};
	ll coef[12]={12, -54, 124, -133, -16, 175, -94, -69, 40, 12, -4, -1};
	ll pat[12][12][65]={};
	for(int i=0;i<12;i++) for(int j=0;j<12;j++){
		if(i!=11){
			if(i+1==j) pat[i][j][0] = 1LL;
		}
		else{
			pat[i][j][0] = coef[11-j];
		}
	}
	for(int k=0;k<64;k++){
		for(int i=0;i<12;i++)for(int j=0;j<12;j++)for(int x=0;x<12;x++){
			pat[i][j][k+1] = (pat[i][j][k+1]+pat[i][x][k]*pat[x][j][k])%mod;
		}
	}
	ll n; cin>>n;
	if(n<=11){cout<<a[n]<<endl;return 0;}
	n-=11;
	for(int k=0;k<64;k++){
		if(!((n>>k)&1LL)) continue;
		ll b[12]={};
		for(int j=0;j<12;j++)for(int x=0;x<12;x++){
			b[j] = (b[j]+pat[j][x][k]*a[x])%mod;
		}
		for(int j=0;j<12;j++) a[j]=b[j];
	}
	cout<<(a[11]%mod+mod)%mod<<endl;
}
0