当前位置:网站首页>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;
}
边栏推荐
- Build your own web page on raspberry pie (1)
- Create a tree structure
- 第四次培训
- [Fine talk] Using native js to implement todolist
- [Harmony OS] [ARK UI] ETS context basic operations
- ss-1.curl (cloud-provider-payment8001)
- Install PostgreSQL on Windows
- 安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
- 接口和抽象
- breed Web刷机升级详细教材修正编译器固件说明_itkeji.top
猜你喜欢
Pr第二次培训笔记
[Harmony OS] [ARK UI] ETS context basic operations
Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
Super handy drawing tool is recommended
Redis常用命令
idea uses @Autowired annotation to explain the reasons and solutions
HarmonyOS应用开发第一次培训
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
typescript45-接口之间的兼容性
Exception(异常) 和 Error(错误)区别解析
随机推荐
Installation of Apache DolphinScheduler version 2.0.5 distributed cluster
idea使用@Autowired注解爆红原因及解决方法
如何不耍流氓的做运维之-SHELL脚本
FileZilla 搭建ftp服务器
对角矩阵(diagonal matrix)
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
IO流及其操作
13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence User password encryption tool
Alienware上线首个数字时装AR试穿体验
typescript44-对象之间的类兼容器
shell脚本循环语句
NotImplementedError: file structure not yet supported
Shell conditional statement judgment
idea uses @Autowired annotation to explain the reasons and solutions
Junit
Odps temporary query can write SQL, turned out to a named?
Object类与常用API
信息编码、存储压缩与密码学
在树莓派上搭建属于自己的网页(2)