思路是这样的

插头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. 通过IP得到IP所在地省市

    /// <summary> /// 通过IP得到IP所在地省市(Porschev) /// </summary> /// <param name="ip&quo ...

  2. noi openjudge7627:鸡蛋的硬度

    http://noi.openjudge.cn/ch0206/7627/ 描述 最近XX公司举办了一个奇怪的比赛:鸡蛋硬度之王争霸赛.参赛者是来自世界各地的母鸡,比赛的内容是看谁下的蛋最硬,更奇怪的是 ...

  3. QEMU编译安装

    QEMU是一个支持跨平台虚拟化的虚拟机,有user mode和system mode两种配置方式.其中qemu在system mode配置下模拟出整个计算机,可以在qemu之上运行一个操作系统.QEM ...

  4. org.springframework.http.converter.HttpMessageNotReadableException

    发起请求报错:org.springframework.http.converter.HttpMessageNotReadableException 查看请求头: application/json 所以 ...

  5. Proxy 和aop

    Proxy 就是代理,意思就是 你不用去做,别人代替你去处理 先来个静态代理 public interface Hello { void say(String name); } 被代理类 public ...

  6. (转)如何真正实现由文档驱动的API设计?

    前言 本文主要介绍了一种新的开发思路:通过反转开发顺序,直接从API文档中阅读代码.作者认为通过这种开发方式,你可以更清楚地知道文档表达出什么以及它应该如何实现. 如果单从API文档出发,由于信息量不 ...

  7. 指针生成网络(Pointer-Generator-Network)原理与实战

    指针生成网络(Pointer-Generator-Network)原理与实战   阅读目录 0 前言 1 Baseline sequence-to-sequence 2 Pointer-Generat ...

  8. Asp.net core 学习笔记 Node Service

    我们知道 npm 是很大的库,很多轮子可以用 所以 .net core 替我们封装了一个调用 nodejs 的 service 就叫 node service 我们只要在 server 安装 node ...

  9. 怎样使用yum安装nginx

    yum install -y nginx 以上.

  10. koa 实现session登陆

    在我们访问一些网站内部内容的时候,通常都会先验证我们是否已经登陆,如果登陆了就跳转到内容页面否则就跳转或者弹出登陆页面. 但是HTTP协议是没有状态的协议,无法标识一个用户的登录状态. 于是Cooki ...