当前位置:网站首页>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;
}边栏推荐
- tensorflow和torch代码验证cuda是否安装成功
- 思维导图+源代码+笔记+项目,字节跳动+京东+360+网易面试题整理
- R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组均值(mean)
- LeetCode-1279. 红绿灯路口
- 保证接口数据安全的10种方案
- A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
- Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
- LeetCode-1279. Traffic light intersection
- R语言使用order函数对dataframe数据进行排序、基于单个字段(变量)进行降序排序(DESCENDING)
- First day of rhcsa study
猜你喜欢
![Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting](/img/dd/c3f4a9c38b156e3a9b9adfd6253773.gif)
Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting

An error occurs when installing MySQL: could not create or access the registry key needed for the

A popular explanation will help you get started

应用使用Druid连接池经常性断链问题分析
![[translation] a GPU approach to particle physics](/img/07/57036c925155cab36678c696e89440.jpg)
[translation] a GPU approach to particle physics

zabbix 代理服务器 与 zabbix-snmp 监控

Synchronous development of business and application: strategic suggestions for application modernization

史上超级详细,想找工作的你还不看这份资料就晚了

Take a look at how cabloyjs workflow engine implements activiti boundary events

Intelligent supply chain management system solution for hardware and electromechanical industry: digital intelligent supply chain "creates new blood" for traditional industries
随机推荐
It's super detailed in history. It's too late for you to read this information if you want to find a job
PMP每日一练 | 考试不迷路-7.6
In depth analysis, Android interview real problem analysis is popular all over the network
Three years of Android development, Android interview experience and real questions sorting of eight major manufacturers during the 2022 epidemic
C # - realize serialization with Marshall class
Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
Looting iii[post sequence traversal and backtracking + dynamic planning]
LeetCode-1279. Traffic light intersection
How word displays modification traces
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图
Php+redis realizes the function of canceling orders over time
Xingnuochi technology's IPO was terminated: it was planned to raise 350million yuan, with an annual revenue of 367million yuan
The slave i/o thread stops because master and slave have equal MySQL serv
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
Tongyu Xincai rushes to Shenzhen Stock Exchange: the annual revenue is 947million Zhang Chi and Su Shiguo are the actual controllers
GCC【7】- 编译检查的是函数的声明,链接检查的是函数的定义bug
R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
A method of removing text blur based on pixel repair
业务与应用同步发展:应用现代化的策略建议
Cereals Mall - Distributed Advanced p129~p339 (end)