当前位置:网站首页>Lick the dog until the last one has nothing (state machine)
Lick the dog until the last one has nothing (state machine)
2022-07-04 13:51:00 【. dye】
Title Description
As the core of the team ,forever97 He is respected by the other two teammates .
Trote_w Please... Every day forever97 Take out , But unfortunately, the center of the universe forever97 There are only 3 home forever97 Favorite takeout .
If Trote_w to forever97 Bought takeout from another family ,forever97 Will shout “ I don't eat I don't eat ”.
however forever97 I don't like to eat a takeout for three days in a row .
If Trote_w One day I forgot about it and bought him the same takeout for three days , that forever97 It will Trote_w Press your head into the screen of your mobile phone .
As Trote_w Good friends , You can tell him to keep asking forever97 eat n Tianfan , How many different ways to buy ?
Input description :
Multiple sets of samples
The first line is an integer T(1<=T<=20) Represents the number of test samples
Next t Each row is an integer n, representative Trote_w Please forever97 eat n Tianfan (1<=n<=100000)
Output description :
Output T An integer represents the number of schemes , Because the answer is too big , You just need to output mod 1e9+7 The answer after .
Example 1
Input
2
3
500
Output
24
544984352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
ll dp[2][100000+10];
int main()
{ ll n,t; cin>>t;
dp[0][1]=3; dp[1][0]=0;
for(int i=2;i<=100000+10;i++)
{
dp[0][i]=(dp[1][i-1]*2+dp[0][i-1]*2)%M;
dp[1][i]=dp[0][i-1]%M;
}
while(t--)
{ cin>>n;
cout<<(dp[0][n]%M+dp[1][n]%M)%M<<endl;
}
}
边栏推荐
- remount of the / superblock failed: Permission denied
- Openharmony application development how to create dayu200 previewer
- 担心“断气” 德国正修改《能源安全法》
- [cloud native | kubernetes] in depth understanding of ingress (12)
- XML入门三
- WPF double slider control and forced capture of mouse event focus
- 面试官:Redis中哈希数据类型的内部实现方式是什么?
- C language staff management system
- Etcd storage, watch and expiration mechanism
- C语言职工管理系统
猜你喜欢
Three schemes to improve the efficiency of MySQL deep paging query
安装trinity、解决报错
unity不识别rider的其中一种解决方法
高效!用虚拟用户搭建FTP工作环境
数据库公共字段自动填充
Byte interview algorithm question
When MDK uses precompiler in header file, ifdef is invalid
Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
ViewBinding和DataBinding的理解和区别
C#/VB. Net to add text / image watermarks to PDF documents
随机推荐
程序员转方向
Read the BGP agreement in 6 minutes.
光环效应——谁说头上有光的就算英雄
安装trinity、解决报错
C language Dormitory Management Query Software
c#数组补充
Service Mesh的基本模式
XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
C#/VB. Net to add text / image watermarks to PDF documents
Zhongang Mining: in order to ensure sufficient supply of fluorite, it is imperative to open source and save flow
In 2022, it will be es2022 soon. Do you only know the new features of ES6?
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Fs4056 800mA charging IC domestic fast charging power IC
"Tips" to slim down Seurat objects
Distributed base theory
XML入门二
Using nsproxy to forward messages
OpenHarmony应用开发之如何创建DAYU200预览器
Node の MongoDB 安装
Deploy halo blog with pagoda