当前位置:网站首页>1230: 蜂巢
1230: 蜂巢
2022-08-03 05:10:00 【-JMY-】
题目描述
一只蜜蜂在下图所示的数字蜂房上爬动,已知它只能从标号小的蜂房爬到标号大的相邻蜂房,现在问你:蜜蜂从蜂房M开始爬到蜂房N,M<N,有多少种爬行路线?

输入
只有一行,是2个用空格隔开的整数M,N(1<=M,N<=60)。
输出
只有1行,1个整数,即有多少种爬行路线。
样例输入
1 3
样例输出
2
(这题其实是找规律,明白规律就很简单了)
参考代码:
#include<bits/stdc++.h>
using namespace std;
long long a[2][60],m,n,l;
int main(){
cin>>m>>n;
a[0][0]=1;
a[1][0]=1;
while(m>1){
m--;
n--;
}
for(l=1;l<=(n-1)/2;l++){
a[0][l]=a[0][l-1]+a[1][l-1];
a[1][l]=a[0][l]+a[1][l-1];
}
cout<<a[1-n%2][l-1];
return 0;
}
边栏推荐
猜你喜欢

力扣561. 数组拆分

typescript39-class类的可见修饰符

Flask的简单介绍及使用方法简介
网络流媒体下载的 10 种方法(以下载 Echo 音乐为例)

typescript41-class类的私有修饰符

Power button 561. An array of split

安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)

Super handy drawing tool is recommended
![[Harmony OS] [ARK UI] ETS context basic operations](/img/40/d5924477c42e2b3246eb212f4be534.png)
[Harmony OS] [ARK UI] ETS context basic operations

Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
随机推荐
typescript49-交叉类型
斐讯K2路由编译Padavan华硕固件和心得
C# async and multithreading
1060 爱丁顿数 (25 分)
ss-5.consul服务端+生产者+消费者
Presto installation and deployment tutorial
Harmony OS Date ano UI 】 【 】 the basic operation
13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence Create a tree structure
web安全-命令执行漏洞
Super handy drawing tool is recommended
High availability, two locations and three centers
Coordinate knowledge in digital twin campus scenarios
Talking about GIS Data (5) - Geographic Coordinate System
Modelarts第一次培训
js实现一个 bind 函数
3n+1问题
Kaggle 入门(Kaggle网站使用及项目复现)
User password encryption tool
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)