当前位置:网站首页>舔狗舔到最后一无所有(状态机)
舔狗舔到最后一无所有(状态机)
2022-07-04 12:44:00 【.染】
题目描述
作为队伍的核心,forever97很受另外两个队友的尊敬。
Trote_w每天都要请forever97吃外卖,但很不幸的是宇宙中心forever97所在的学校周围只有3家forever97爱吃的外卖。
如果Trote_w给forever97买了别家的外卖,forever97就会大喊“我不吃我不吃”。
但是forever97又不喜欢连续三天吃一种外卖。
如果Trote_w哪天忘了这件事并且三天给他买了同一家外卖,那么forever97就会把Trote_w的头摁进手机屏幕里。
作为Trote_w的好朋友,你能告诉他连续请forever97吃n天饭,有多少不同的购买方法吗?
输入描述:
多组样例
第一行一个整数T(1<=T<=20)代表测试样例数
接下来t行每行一个整数n,代表Trote_w要请forever97吃n天饭(1<=n<=100000)
输出描述:
输出T个整数代表方案数,由于答案太大,你只需要输出mod 1e9+7 后的答案即可。
示例1
输入
2
3
500
输出
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;
}
}
边栏推荐
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- C language Dormitory Management Query Software
- Runc hang causes the kubernetes node notready
- Introduction to XML II
- How real-time cloud interaction helps the development of education industry
- 使用宝塔部署halo博客
- C#基础补充
- . Net using redis
- Dgraph: large scale dynamic graph dataset
- .NET 使用 redis
猜你喜欢

7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多

求解:在oracle中如何用一条语句用delete删除两个表中jack的信息

一个数据人对领域模型理解与深入

Commvault 和 Oracle 合作,在 Oracle 云上提供 Metallic数据管理即服务

The only core indicator of high-quality software architecture

Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation

8个扩展子包!RecBole推出2.0!

JVM系列——栈与堆、方法区day1-2

CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合

n++也不靠谱
随机推荐
Rsyslog配置及使用教程
诸神黄昏时代的对比学习
Using nsproxy to forward messages
一个数据人对领域模型理解与深入
XML入门三
Reading cognitive Awakening
Valentine's Day confession code
Optional values and functions of the itemized contenttype parameter in the request header
Zhongang Mining: in order to ensure sufficient supply of fluorite, it is imperative to open source and save flow
Comparative study of the gods in the twilight Era
8 expansion sub packages! Recbole launches 2.0!
Use fail2ban to prevent password attempts
提高MySQL深分页查询效率的三种方案
Cors: standard scheme of cross domain resource request
Agile development / agile testing experience
eclipse链接数据库中测试SQL语句删除出现SQL语句语法错误
FS4056 800mA充电ic 国产快充电源ic
C basic supplement
Scrapy 框架学习
使用Scrcpy投屏