結果

問題 No.569 3 x N グリッドのパスの数
ユーザー IL_mstaIL_msta
提出日時 2017-09-09 10:04:43
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 2,169 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 108,068 KB
実行使用メモリ 817,024 KB
最終ジャッジ日時 2024-04-24 23:35:33
合計ジャッジ時間 2,893 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

/*
http://www.iwriteiam.nl/Crook_path.html
http://www.iwriteiam.nl/counting.html

意味は分からない
*/
map<LL,LL> memo;

LL f(LL n){
	if( memo.find(n) != memo.end() ){
		return memo[n];
	}
	LL ans = 0;
	ans = (f(n-1)*12) % MOD;
	ans = (ans+f(n-3)*124) % MOD;
	ans = (ans+f(n-6)*175) % MOD;
	ans = (ans+f(n-9)*40) % MOD;
	ans = (ans+f(n-10)*12) % MOD;


	LL res = (f(n-2)*54) % MOD;
	res = (res+f(n-4)*133) % MOD;
	res = (res+f(n-5)*16) % MOD;
	res = (res+f(n-7)*94) % MOD;
	res = (res+f(n-8)*69) % MOD;
	res = (res+f(n-11)*4) % MOD;
	res = (res+f(n-12)) % MOD;
	
	res = (MOD - res) % MOD;
	ans = (ans+res) % MOD;
	memo[n] = ans;
	return ans;
}
void solve(){
	LL N;
	cin >> N;
	++N;
	memo[1] = 1;
	memo[2] = 8;
	memo[3] = 38;
	memo[4] = 184;
	memo[5] = 976;
	memo[6] = 5382;
	memo[7] = 29739;
	memo[8] = 163496;
	memo[9] = 896476;
	memo[10] = 4913258;
	memo[11] = 26932712;
	memo[12] = 147657866;
	
	cout << f(N) << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()
0