思路是这样的

插头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. Mysql批量插入返回Id错乱(原因分析)

    在项目中经常会有如下场景: 往数据库中批量插入一批数据后,需要知道哪些插入成功,哪些插入失败了. 这时候往往会有两种思路,一个是在插入之前判断相同的记录是否存在,过滤掉重复的数据:另外一种就是边插入边 ...

  2. docker 运行pptpd服务器

      今天试着用docker搭了一下pptpd服务器,感觉清爽不少(当然是踩坑之后的啦),特此记录.   使用的镜像: mmontagna/docker-vpn-pptp   由于是现成的镜像,所以我们 ...

  3. C++11 thread condition_variable mutex 综合使用

    #include <mutex> #include <condition_variable> #include <chrono> #include <thre ...

  4. [转帖]tr命令的用法

    tr命令的用法 https://www.cnblogs.com/bingguoguo/articles/9188703.html tr命令   tr命令可以对来自标准输入的字符进行替换.压缩和删除.它 ...

  5. (五)Spring 中的 aop

    目录 文章目录 AOP概念 AOP原理 AOP术语 **`Spring`** 中的 **`aop`** 的操作 使用 `AspectJ` 实现 `aop` 的两种方式 AOP概念 浅理解 aop :面 ...

  6. k-近邻(KNN) 算法预测签到位置

    分类算法-k近邻算法(KNN): 定义: 如果一个样本在特征空间中的k个最相似 (即特征空间中最邻近) 的样本中的大多数属于某一个类别,则该样本也属于这个类别 来源: KNN算法最早是由Cover和H ...

  7. FastAdmin

    FastAdmin是一款基于ThinkPHP5+Bootstrap的极速后台开发框架. 感觉挺好用的. 开发文档https://doc.fastadmin.net/docs/index.html 根据 ...

  8. python以不同方式打印输出九九乘法表

    参考:http://www.cnblogs.com/suiy-160428/p/5594389.htmlpython输出 9*9 乘法口诀表 矩形输出九九乘法表: for i in range(1,1 ...

  9. 关于BIOS系统的认识和学习(源自摘录)

    BIOS系统的介绍与学习 BIOS (basic input output system 即基本输入输出系统)在计算机系统中起着非常重要的作用,其是计算机系统最底层的设置, BIOS设置程序是被固化到 ...

  10. github骚操作

    限制搜索 in关键词限制搜索范围 命令 说明 xxx in:name 项目名包含xxx的 xxx in:description 项目描述包含xxx的 xxx in:readme 项目的readme文件 ...