谁能帮帮我啊·!

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;
}
:sob: :sob: :sob: :sob: :sob: :sob: :sob: :sob:
@林品逸 你做出来了吧?

4 个赞

答案对998244353取模。

5 个赞

在a[i]=a[i-1]+a[i-2]+a[i-3];下面

4 个赞

干什么

5 个赞

对998244353取模

4 个赞

怎么取模

5 个赞

a[i]=a[i]%998244353; :joy:

5 个赞

给个解决方案

5 个赞

#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];
a[i]%=998244353;
}
cout<<a[n]<<endl;
return 0;
}
还是WA :sob: :sob: :sob:

5 个赞

等等

5 个赞

int a[1005],f[1005];
int 改 long long

5 个赞

一定过,给个解决方案

4 个赞

你对我的期望太大了 :stuck_out_tongue_winking_eye:

3 个赞

对不起昨天晚上被我妈逼着睡觉去了
但解决方案给了

6 个赞

Ok

2 个赞