当前位置:网站首页>Lick the dog until the last one has nothing (simple DP)
Lick the dog until the last one has nothing (simple DP)
2022-07-06 19:24:00 【surowvv】
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
analysis :
about a,b,c Three takeaways , Hypothesis number 1 i God eat a, Then the number of schemes is i-1 God eat a+ The first i-1 God eat b+ The first i-1 God eat c;
Among them the first i-1 God eat a when , The first i-2 It's impossible to eat a, Can only eat b or c.
So the first i God eat a Number of schemes Actually, it is No i-2 God eat b+ The first i-2 God eat c+ The first i-1 God eat b+ The first i-1 God eat c;
The same goes for the other two takeout .
The first i God eat b Number of schemes Actually, it is No i-2 God eat a+ The first i-2 God eat c+ The first i-1 God eat a+ The first i-1 God eat c;
The first i God eat c Number of schemes Actually, it is No i-2 God eat a+ The first i-2 God eat b+ The first i-1 God eat a+ The first i-1 God eat b;
All in all , The first i Number of prescriptions = The first i-2 Number of prescriptions *2+ The first i-1 Number of prescriptions *2;
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int f[100010];
int main()
{
int T;
cin >> T;
f[1] = 3, f[2] = 9;
while (T--) {
int x;
cin >> x;
for (int i = 3; i <= x; i++) f[i] = (f[i - 1] + f[i - 2]) % mod * 2 % mod;
cout << f[x] << endl;
}
return 0;
}边栏推荐
- [translation] a GPU approach to particle physics
- LeetCode_格雷编码_中等_89.格雷编码
- [pytorch] yolov5 train your own data set
- 如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
- It's super detailed in history. It's too late for you to read this information if you want to find a job
- How can my Haskell program or library find its version number- How can my Haskell program or library find its version number?
- 终于可以一行代码也不用改了!ShardingSphere 原生驱动问世
- R语言使用order函数对dataframe数据进行排序、基于单个字段(变量)进行降序排序(DESCENDING)
- Interface test tool - postman
- Modulenotfounderror: no module named 'PIL' solution
猜你喜欢

接雨水问题解析

Simple understanding of MySQL database

php+redis实现超时取消订单功能

It's super detailed in history. It's too late for you to read this information if you want to find a job

Lucun smart sprint technology innovation board: annual revenue of 400million, proposed to raise 700million

Mathematical knowledge -- code implementation of Gaussian elimination (elementary line transformation to solve equations)

Cereals Mall - Distributed Advanced p129~p339 (end)
Three years of Android development, Android interview experience and real questions sorting of eight major manufacturers during the 2022 epidemic

Pychrm Community Edition calls matplotlib pyplot. Solution of imshow() function image not popping up
时钟轮在 RPC 中的应用
随机推荐
Intelligent supply chain management system solution for hardware and electromechanical industry: digital intelligent supply chain "creates new blood" for traditional industries
The nearest library of Qinglong panel
关于图像的读取及处理等
Simple application of VBA script in Excel
Use of deg2rad and rad2deg functions in MATLAB
Mysql Information Schema 学习(二)--Innodb表
Based on butterfly species recognition
Spark foundation -scala
The list of people who passed the fifth phase of personal ability certification assessment was published
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置add参数为不同水平点状条带图添加箱图
Tensorflow and torch code verify whether CUDA is successfully installed
R language uses DT function to generate t-distribution density function data and plot function to visualize t-distribution density function data
Interface test tool - postman
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图
Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
Translation D28 (with AC code POJ 26:the nearest number)
MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
LeetCode-1279. 红绿灯路口
spark基础-scala
Elastic search indexes are often deleted [closed] - elastic search indexes gets deleted frequently [closed]