当前位置:网站首页>舔狗舔到最后一无所有(状态机)
舔狗舔到最后一无所有(状态机)
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;
}
}
边栏推荐
- n++也不靠谱
- JVM系列——栈与堆、方法区day1-2
- mysql三级分销代理关系存储
- XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
- 聊聊支付流程的设计与实现逻辑
- 请问大佬们有遇到这个情况吗,cdc 1.4 连接MySQL 5.7 无法使用 timestamp
- Optional values and functions of the itemized contenttype parameter in the request header
- 游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
- 2022年中国移动阅读市场年度综合分析
- 7、 Software package management
猜你喜欢
HAProxy高可用解决方案
[AI system frontier dynamics, issue 40] Hinton: my deep learning career and research mind method; Google refutes rumors and gives up tensorflow; The apotheosis framework is officially open source
CommVault cooperates with Oracle to provide metallic data management as a service on Oracle cloud
After installing vscode, the program runs (an include error is detected, please update the includepath, which has been solved for this translation unit (waveform curve is disabled) and (the source fil
PostgreSQL 9.1 soaring Road
Dgraph: large scale dynamic graph dataset
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
Meituan Ali's Application Practice on multimodal recall
上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
Practice: fabric user certificate revocation operation process
随机推荐
C#/VB. Net to add text / image watermarks to PDF documents
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Samsung's mass production of 3nm products has attracted the attention of Taiwan media: whether it can improve the input-output rate in the short term is the key to compete with TSMC
【AI系统前沿动态第40期】Hinton:我的深度学习生涯与研究心法;Google辟谣放弃TensorFlow;封神框架正式开源
比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟
C language Dormitory Management Query Software
c#数组补充
"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
CommVault cooperates with Oracle to provide metallic data management as a service on Oracle cloud
Valentine's Day confession code
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
Zhongang Mining: in order to ensure sufficient supply of fluorite, it is imperative to open source and save flow
6 分钟看完 BGP 协议。
Flet教程之 03 FilledButton基础入门(教程含源码)(教程含源码)
Using nsproxy to forward messages
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
XML入门三
Cors: standard scheme of cross domain resource request
Alibaba cloud award winning experience: build a highly available system with polardb-x
go-zero微服务实战系列(九、极致优化秒杀性能)