Plant(𝐶𝑜𝑑𝑒𝐹𝑜𝑟𝑐𝑒𝑠 − 185𝐴)
#include<iostream>
#include<cstring>
using namespace std; const int maxn=,mod=; struct Matrix
{
long long mat[maxn][maxn];
Matrix operator*(const Matrix& m)const///重载*运算符,使其能进行矩阵相乘的运算
{
Matrix tmp;
for(int i = ; i < maxn ; i++)
{
for(int j = ; j < maxn ; j++)
{
tmp.mat[i][j] = ;
for(int k = ; k < maxn ; k++)
{
tmp.mat[i][j] += mat[i][k]*m.mat[k][j]%mod;
tmp.mat[i][j] %= mod; }
}
}
return tmp;
}
}; Matrix m; void init()
{
m.mat[][]=;
m.mat[][]=;
m.mat[][]=;
m.mat[][]=;
} long long run(long long n)
{
Matrix ans;
memset(ans.mat,,sizeof(ans.mat));
for(int i=; i<; i++)
ans.mat[i][i]=;
while(n)
{
if(n&)
ans=ans*m;
n>>=;
m=m*m;
}
return ans.mat[][];
} int main()
{
long long n;
while(cin>>n)
{
init();
cout<<run(n)<<endl;
}
return ;
}
Plant(𝐶𝑜𝑑𝑒𝐹𝑜𝑟𝑐𝑒𝑠 − 185𝐴)的更多相关文章
- Codeforces Round #118 (Div. 1) A. Plant
A. Plant 题目链接:http://codeforces.com/problemset/problem/185/A 题意:一个植物会长,一开始是一个正三角形,每过一年,一个向上的正三角形会变成三 ...
- Plant (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/185/A 题目: Dwarfs have planted a very interesting plant ...
- Plant Design Review Based on AnyCAD
Plant Design Review Based on AnyCAD eryar@163.com Abstract. AVEVA Review is used to 3D model visuali ...
- 【BZOJ 4455】【UOJ #185】【ZJOI 2016】小星星
http://www.lydsy.com/JudgeOnline/problem.php?id=4455 http://uoj.ac/problem/185 有一个$O(n^n)$的暴力,放宽限制可以 ...
- EWM一个仓库号对应ERP多个PLANT的配置
1. CIF多个DC到EWM系统,创建SCU并配置成仓 2. tx:/sapapo/loc3 对多个DC生成分配模型 3. IMG:分配仓库编号 去掉缺省的授权处理方 4. 维护SCU hierarc ...
- 2014年最大福利:185个Google排名因素!免费电子书下载
本博开张以来最大规模的干货放送!新手老手都有用! 不要再去追求PR了,不要再去发博客发论坛发外链了! 关注真正有用的Google排名因素! 整整185项,每一项都附带说明,必要的地方会给出一些附加的阅 ...
- [转帖]SAP一句话入门:Plant Maintenance
SAP一句话入门:Plant Maintenance http://blog.vsharing.com/MilesForce/A618273.html PM就是Plant Maintenance(本文 ...
- 185. [USACO Oct08] 挖水井
185. [USACO Oct08] 挖水井(点击转到COGS) 输入文件:water.in 输出文件:water.out 时间限制:1 s 内存限制:128 MB 描述 农夫约翰决定给他 ...
- centos 7 IP不能访问nginx Failed connect to 185.239.226.111:80; No route to host解决办法
服务器环境 centos 7.4 问题描述 1.可以ping通IP ,用IP访问nginx 不能访问,在服务器上curl localhost curl 185.239.226.111可以获得 [ro ...
随机推荐
- javascript中的require、import和export模块文件
CommonJS 方式 文件输出如math.js: math.add = function(a,b){ return a+b; }exports.math = math; 文件引入: math = r ...
- ubuntu 调节音量命令 声卡驱动
alsamixer 安装驱动http://www.realtek.com/downloads/downloadsCheck.aspx?Langid=1&PNid=24&PFid=24& ...
- jar包在控制台下运行
今天有个项目需要在控制台下面运行jar文件 流程 1 新建java项目 2 新建 HelloWorld.java public class HelloWorld { public static voi ...
- Vue + Element UI 实现权限管理系统(动态加载菜单)
动态加载菜单 之前我们的导航树都是写死在页面里的,而实际应用中是需要从后台服务器获取菜单数据之后动态生成的. 我们在这里就用上一篇准备好的数据格式Mock出模拟数据,然后动态生成我们的导航菜单. 接口 ...
- Fiddler系列教程2:手机抓包图文教程
上篇Fiddler教程,我们教了大家Fiddler安装配置及如何使用Fiddler进行基本的Http抓包及模拟请求,今天给大家介绍下如何使用Fiddler进行手机抓包. 运行环境为Windows 10 ...
- angular4-http
导入 Http 模块 import { HttpModule } from '@angular/http'; @NgModule({ imports: [BrowserModule, FormsMod ...
- 《Python》hashlib模块、configparser模块、logging模块
一.hashlib模块 Python的hashlib模块中提供了常见的摘要算法,如md5,sha1等等. 摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的字符串(通 ...
- Cracking The Coding Interview 4.7_暂存
//原文: // // You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds ...
- 对编译特性(* ASYNC_REG = “TRUE” *)的理解
(*ASYNC_REG = "TRUE"*)命令用于声明寄存器能够接收相对于时钟源的异步数据,或者说寄存器是一个同步链路上正在同步的寄存器.这条命令可以放在任何寄存器上,除了设置它 ...
- UI控件Telerik UI for WinForms发布R1 2019|附下载
Telerik UI for WinForms拥有适用Windows Forms的110多个令人惊叹的UI控件.所有的UI for WinForms控件都具有完整的主题支持,可以轻松地帮助开发人员在桌 ...