当前位置:网站首页>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;
}
}
边栏推荐
- C语言职工管理系统
- Scripy framework learning
- Is the outdoor LED screen waterproof?
- .NET 使用 redis
- 易周金融 | Q1保险行业活跃人数8688.67万人 19家支付机构牌照被注销
- Using nsproxy to forward messages
- Alibaba cloud award winning experience: build a highly available system with polardb-x
- 上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
- 一个数据人对领域模型理解与深入
- C语言程序设计选题参考
猜你喜欢
Openharmony application development how to create dayu200 previewer
Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements
OPPO Find N2产品形态首曝:补齐各项短板
Go 语言入门很简单:Go 实现凯撒密码
Source code compilation and installation of MySQL
Annual comprehensive analysis of China's mobile reading market in 2022
Dgraph: large scale dynamic graph dataset
基于链表管理的单片机轮询程序框架
ASP.NET Core入门一
2022KDD预讲 | 11位一作学者带你提前解锁优秀论文
随机推荐
三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键
Besides, rsync+inotify realizes real-time backup of data
C语言个人通讯录管理系统
聊聊支付流程的设计与实现逻辑
结合案例:Flink框架中的最底层API(ProcessFunction)用法
The only core indicator of high-quality software architecture
"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
WPF double slider control and forced capture of mouse event focus
模块化笔记软件综合评测:Craft、Notion、FlowUs
一个数据人对领域模型理解与深入
嵌入式编程中五个必探的“潜在错误”
光环效应——谁说头上有光的就算英雄
C array supplement
微服务入门
C语言图书租赁管理系统
程序员转方向
Node の MongoDB 安装
ViewBinding和DataBinding的理解和区别
#yyds干货盘点# 解决名企真题:连续最大和
C language Dormitory Management Query Software