結果
| 問題 |
No.569 3 x N グリッドのパスの数
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2017-09-09 10:04:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,169 bytes |
| コンパイル時間 | 1,121 ms |
| コンパイル使用メモリ | 108,552 KB |
| 実行使用メモリ | 817,792 KB |
| 最終ジャッジ日時 | 2024-11-07 08:54:22 |
| 合計ジャッジ時間 | 3,680 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 MLE * 1 -- * 39 |
ソースコード
#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()
IL_msta