思路是这样的

插头dp-->打表-->OEIS查表-->通项公式-->矩阵快速幂优化线性递推

OEIS竟然有这个东西的生成函数啊

答案为15836928

这是最终代码

#include <bits/stdc++.h>

using namespace std;

#define MOD 191981
#define mod 100000000
#define ll long long struct Matrix {
vector<vector<int> > a;
int n, m;
void init(int n, int m) {
this->n = n, this->m = m;
a.resize(n);
for(int i = 0; i < n; ++i) a[i].resize(m);
}
vector<int>& operator [](int index_x) {
return a[index_x];
}
friend Matrix operator * (Matrix lhs, Matrix rhs) {
Matrix c;
c.init(lhs.n, rhs.m);
for(int i = 0; i < lhs.n; ++i)
for(int j = 0; j < rhs.m; ++j)
for(int k = 0; k < lhs.m; ++k)
c[i][j] = (c[i][j]+1LL*lhs[i][k]*rhs[k][j]%mod)%mod;
return c;
}
}; Matrix eye(int n) {
Matrix c;
c.init(n, n);
for(int i = 0; i < n; ++i)
c[i][i] = 1;
return c;
} Matrix fpow(Matrix x, ll p) {
Matrix ret = eye(x.n);
while(p) {
if(p&1) ret = ret*x;
x = x*x;
p >>= 1;
}
return ret;
} //a(n) = 2*a(n-1) + 2*a(n-2) - 2*a(n-3) + a(n-4) int main() {
ll n;
scanf("%lld", &n);
if(n == 1) printf("1\n");
else if(n == 2) printf("1\n");
else if(n == 3) printf("4\n");
else if(n == 4) printf("8\n");
else {
Matrix m0, p, ans;
m0.init(4, 1);
m0[0][0] = 8, m0[1][0] = 4, m0[2][0] = 1, m0[3][0] = 1;
p.init(4, 4);
p[0][0] = 2, p[0][1] = 2, p[0][2] = -2, p[0][3] = p[1][0] = p[2][1] = p[3][2] = 1;
ans = fpow(p, n-4)*m0;
printf("%d\n", ans[0][0]);
}
return 0;
}

ProjectEuler237 Tours on a 4 x n playing board的更多相关文章

  1. jquery开发的数字相加游戏(你能玩几分)

    jquery开发的数字相加游戏,我在一轮中玩了632分(如下图),你能玩几分,哈哈... 我要试一试 下面贡献下这款“数字相加游戏”的开发过程. html部分: <div class=" ...

  2. Machine Learning and Data Mining(机器学习与数据挖掘)

    Problems[show] Classification Clustering Regression Anomaly detection Association rules Reinforcemen ...

  3. (转) Playing FPS games with deep reinforcement learning

    Playing FPS games with deep reinforcement learning 博文转自:https://blog.acolyer.org/2016/11/23/playing- ...

  4. Web Tours自带示例网站无法打开的解决方案

    问题现象: LoadRunner自带的测试样品,旅行社机票预订系统HP Web Tours以下简称为Web Tours. 1.LoadRunner程序的Sample目录下无Web和Web Tours服 ...

  5. (转) Deep Reinforcement Learning: Playing a Racing Game

    Byte Tank Posts Archive Deep Reinforcement Learning: Playing a Racing Game OCT 6TH, 2016 Agent playi ...

  6. Codeforces Round #184 (Div. 2) E. Playing with String(博弈)

    题目大意 两个人轮流在一个字符串上删掉一个字符,没有字符可删的人输掉游戏 删字符的规则如下: 1. 每次从一个字符串中选取一个字符,它是一个长度至少为 3 的奇回文串的中心 2. 删掉该字符,同时,他 ...

  7. ifrog-1028 Bob and Alice are playing numbers(trie树)

    题目链接: Bob and Alice are playing numbers DESCRIPTION Bob and his girl friend are playing game togethe ...

  8. URAL 1077 Travelling Tours(统计无向图中环的数目)

    Travelling Tours Time limit: 1.0 secondMemory limit: 64 MB There are N cities numbered from 1 to N ( ...

  9. 论文笔记之:Playing for Data: Ground Truth from Computer Games

    Playing for Data: Ground Truth from Computer Games ECCV 2016 Project Page:http://download.visinf.tu- ...

随机推荐

  1. IO阻塞模型、IO非阻塞模型、多路复用IO模型

    IO操作主要包括两类: 本地IO 网络IO 本地IO:本地IO是指本地的文件读取等操作,本地IO的优化主要是在操作系统中进行,我们对于本地IO的优化作用十分有限 网络IO:网络IO指的是在进行网络操作 ...

  2. solr后台操作Documents之增删改查

    偶尔会用到solr后台操作一些数据,比如测试等一些情况.但具体用的时候可能会忘记,或者搜的时候结果不全,在此略详细的记一下. 1.添加 {"id":6,"title&qu ...

  3. 要求设计 LazyMan 类,实现以下功能

    LazyMan('Tony'); // Hi I am Tony LazyMan('Tony').sleep(10).eat('lunch'); // Hi I am Tony // 等待了10秒.. ...

  4. Java总复习内容

    StringBuffer定义时需要用正确的方式 例如: StringBuffer xxx = new StringBuffer("雯雯是猪"); 使用StringBuffer的连接 ...

  5. postgresSQL常用命令

    1.createdb 数据库名称  产生数据库2.dropdb  数据库名称  删除数据库 3.CREATE USER 用户名称  创建用户4.drop User 用户名称  删除用户 5.SELEC ...

  6. url-pattern / 与/* 的区别

    其中/和/*的区别:< url-pattern>/</url-pattern> 会匹配到/login这样的路径型url 不会匹配到模式为*.jsp这样的后缀型url,即:*.j ...

  7. SpringCloud 教程 | 终章

    错过了这一篇,你可能再也学不会 Spring Cloud 了!Spring Boot做为下一代 web 框架,Spring Cloud 作为最新最火的微服务的翘楚,你还有什么理由拒绝.赶快上船吧,老船 ...

  8. 网络流基础&网络流24题

    网络最大流 dinic+当前弧优化. const int N=10007,M=100007,inf=1e9; int s,t,head[N],ver[M],edge[M],Next[M],tot=1, ...

  9. MySQL的安装 --windows版本

    下载 第一步:打开网址,https://www.mysql.com/ ,点击downloads之后跳转到 https://www.mysql.com/downloads/ 第二步 :跳转至网址 htt ...

  10. Django-djangorestframework-异常模块-源码及自定义异常

    目录 异常模块 为什么要自定义异常模块 常见的几种异常情况 异常模块源码分析 自定义 drf 异常处理 异常模块 为什么要自定义异常模块 所有经过 drf APIView 视图类产生的异常,都可以提供 ...