A. 爬楼梯
Problem ID: 9243
Contest ID: 6058
必做题
时间限制: 2000ms
空间限制: 256000kB
题目描述
一段楼梯有n级台阶。你每次可以爬一格、走两格或者跨三格。问你最终有几种方案?答案对998244353取模。
输入格式
一行一个数n。
输出格式
一行一个数,表示方案数。
样例
Input 1
3
Output 1
4
数据范围
n≤1000n≤1000
谁能帮我看看为什么WA
下面是我的代码
#include<bits/stdc++.h>
using namespace std;
int a[1005],f[1005];
int main(){
a[1]=1;
a[2]=2;
a[3]=4;
int n;
cin>>n;
for(int i=4;i<=n;i++){
a[i]=a[i-1]+a[i-2]+a[i-3];
}
cout<<a[n];
return 0;
}[quote=“潘葛宇, post:1, topic:11452, full:true, username:潘葛宇”]
A. 爬楼梯
Problem ID: 9243
Contest ID: 6058
必做题
时间限制: 2000ms
空间限制: 256000kB
题目描述
一段楼梯有n级台阶。你每次可以爬一格、走两格或者跨三格。问你最终有几种方案?答案对998244353取模。
输入格式
一行一个数n。
输出格式
一行一个数,表示方案数。
样例
Input 1
3
Output 1
4
数据范围
n≤1000n≤1000
谁能帮我看看为什么WA
下面是我的代码
#include<bits/stdc++.h>
using namespace std;
int a[1005],f[1005];
int main(){
a[1]=1;
a[2]=2;
a[3]=4;
int n;
cin>>n;
for(int i=4;i<=n;i++){
a[i]=a[i-1]+a[i-2]+a[i-3];
}
cout<<a[n];
return 0;
}
![]()
@林品逸 你做出来了吧?