当前位置:网站首页>牛客动态规划训练
牛客动态规划训练
2022-07-25 07:51:00 【勇敢nn】

#include<iostream>
using namespace std;
int t;
long long f[100];
void init()
{
f[1]=1;
f[2]=2;
for(int i=3;i<=80;i++)
{
f[i]=f[i-1]+f[i-2];
}
}
int main()
{
init();
cin>>t;
int n;
while(t--)
{
scanf("%d",&n);
printf("%lld\n",f[n]);
}
return 0;
}

#include<iostream>
using namespace std;
const int mod=1e9+7;
int t;
int f[100010];
int main()
{
cin>>t;
int n;
f[1]=3;
f[2]=9;
while(t--)
{
scanf("%d",&n);
for(int i=3;i<=n;i++)
{
f[i]=(2*((f[i-1]+f[i-2])%mod))%mod;
}
printf("%d\n",f[n]);
}
return 0;
}

#include<iostream>
using namespace std;
int t;
long long f(long long n)
{
if(n<=2) return 0;
else if(n==3) return 1;
else
{
if(n%2==0) return 2*f(n/2);
else return f(n/2)+f(n/2+1)+1;
}
}
int main()
{
cin>>t;
long long n;
while(t--)
{
scanf("%lld",&n);
printf("%lld\n",f(n));
}
return 0;
}
边栏推荐
- Room database migration
- 全新8.6版本SEO快排系统(可源码级搭建)
- [unity introduction program] basic concepts -2d rigid body 2D
- 【Unity入门计划】基本概念-2D碰撞体Collider 2D
- 文件详细操作
- 【Unity入门计划】基本概念-GameObject&Components
- Growth path - InfoQ video experience notes [easy to understand]
- 转行学什么成为了一大部分人的难题,那么为什么很多人学习软件测试呢?
- Redis client tool redis insight recommendation
- UNIPRO multi terminal deployment to meet customers' diversified needs
猜你喜欢

【Unity入门计划】基本概念-触发器 Trigger

纳米数据足球数据,足球赛事比分,体育数据api,卡塔尔世界杯
![[unity introduction program] basic concepts - 2D collider collider 2D](/img/cf/a546238a5eaf4707006ecf1b7f19c6.png)
[unity introduction program] basic concepts - 2D collider collider 2D

Teach you to use cann to convert photos into cartoon style

Configuring WAPI certificate security policy for Huawei wireless devices

Supplementary notes on Relevant Issues of complete model group

Pads export Gerber file

Cerebral cortex: the relationship between lifestyle and brain function in the elderly and its relationship with cognitive decline

机器学习入门详解(一):理解监督学习中的最大似然估计

【论文笔记】Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized
随机推荐
Polling, interrupt, DMA and channel
yolov7 网络架构深度解析
[unity entry program] basic concept trigger
Redis client tool redis insight recommendation
A fast method of data set enhancement for deep learning
Huawei wireless device configuration wpa2-802.1x-aes security policy
while(~scanf(“%d“, &n)) 等价于 while(scanf(“%d“,&n)!=EOF)
[unity introduction program] basic concepts - 2D collider collider 2D
如何仅用递归函数和栈操作逆序一个栈
文件详细操作
Load capacity - sorting out the mind map that affects load capacity
【微信小程序】全局样式、局部样式、全局配置
Science: listening to music can really relieve pain. Chinese scientists reveal the neural mechanism behind it
整数a按位取反(~)后的值为-(a+1)
使用CycleGAN训练自己制作的数据集,通俗教程,快速上手
toolbar的使用
How should enterprise users choose aiops or APM?
Vs2019 C MFC installation
[software testing] package resume from these points to improve the pass rate
Weblux default IO threads