当前位置:网站首页>1091: two or three things in childhood (multi instance test)
1091: two or three things in childhood (multi instance test)
2022-07-06 07:06:00 【Huaze flowers】
Title Description
Redraiment When I was a child, I liked to walk and jump , He likes to jump up and down the stairs best .
But when he was young, he could only go up one step at a time or jump up two steps at once .
Now there is N Steps , Please calculate Redraiment From 0 Step to N There are several ways to walk the steps .
Input
Input includes multiple sets of data .
Each set of data includes a row :N(1≤N≤40).
Enter to 0 end
Output
Each input includes an output .
by redraiment Arrive at n The number of different steps .
The sample input
1 3 0
Sample output
1 3
// Take one step , Jump two steps , from 0 Go to the N rank , Several walking methods
// Enter multiple groups N, With 0 end
// Output several ways
// Input :
//1
//3
//0
// Output :
//1
//3
#include <stdio.h>
int main()
{
int n,a[100],b,i;
a[0]=1;
a[1]=2;
while(scanf("%d",&n))
{
if(n==0)
break;
if(n==1)
printf("1\n");
else if(n==2)
printf("2\n");
else if(n>2)
{
for(i=2;i<=n;i++)
{
a[i]=a[i-1]+a[i-2];
}
printf("%d\n",a[n-1]);
}
}
return 0;
}
Running results :

Submit :
![]()
According to the title , You can find it by listing a few numbers , Fibonacci series can be used to calculate
Simply list a few examples of using Fibonacci sequence :
1. The bifurcation of trees
2. Number of petals
3. Rabbit breeding
4.1,2 Go up the steps
边栏推荐
- 同事上了个厕所,我帮产品妹子轻松完成BI数据产品顺便得到奶茶奖励
- Pallet management in SAP SD delivery process
- Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
- Simple use of JWT
- 软件测试外包到底要不要去?三年真实外包感受告诉你
- Blue Bridge Cup zero Foundation National Championship - day 20
- Fast target recognition based on pytorch and fast RCNN
- TS基础篇
- Depth residual network
- Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)
猜你喜欢

ROS学习_基础

Top test sharing: if you want to change careers, you must consider these issues clearly!

AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm

How to reconstruct the class explosion caused by m*n strategies?

Establishment and operation of cloud platform open source project environment

AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models. common‘ from ‘/home/yolov5/models/comm

Hydra common commands

A brief introduction of reverseme in misc in the world of attack and defense

漏了监控:Zabbix对Eureka instance状态监控

leetcode704. Binary search (find an element, simple, different writing)
随机推荐
Wechat official account infinite callback authorization system source code, launched in the whole network
Huawei equipment configuration ospf-bgp linkage
数据仓库建设思维导图
Visitor tweets about how you can layout the metauniverse
Hydra common commands
基于PyTorch和Fast RCNN快速实现目标识别
Prefix and array series
【Hot100】739. 每日温度
变量的命名规则十二条
Missing monitoring: ZABBIX monitors the status of Eureka instance
【每日一题】729. 我的日程安排表 I
18. Multi level page table and fast table
Misc of BUU (update from time to time)
What does UDP attack mean? UDP attack prevention measures
Leetcode59. spiral matrix II (medium)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Blue Bridge Cup zero Foundation National Championship - day 20
AI on the cloud makes earth science research easier
ROS2安装及基础知识介绍
kubernetes集群搭建Zabbix监控平台