大佬帮我看看呗,只有第一个AC,其他都是WA+RE,解答必关!!!

P1192 台阶问题

@[ikenyzh](/user/1061522) 第一,你的数组开小了,第二你要在`a[i-j]`应改成`i-j<0?0:a[i-j]`否则你会出现上溢+下溢双重问题
by Whycmd @ 2024-02-16 21:24:19


```cpp #include<bits/stdc++.h> using namespace std; int a[/*-->*/100005/*<--*/],b,c; int main() { cin >>b>>c; /*-->*/a[1]/*<--*/=a[0]=1; for(int i=/*-->*/2/*<--*/;i<=b;i++) { for(int j=1;j<=c/*-->*/ && j<=i/*<--*/;j++) a[i]=(a[i]+a[i-j])%100003; } cout <<a[b]; return 0; } ``` [AC记录](https://www.luogu.com.cn/record/147099875)
by Kayisama @ 2024-02-16 21:27:03


@[ikenyzh](/user/1061522) ``` #include<bits/stdc++.h> using namespace std; int a[100001],b,c; int main() { cin >>b>>c; a[0]=a[1]=1; for(int i=2;i<=b;i++) { for(int j=1;j<=c;j++) if(i>=j) a[i]=(a[i]+a[i-j])%100003; } cout <<a[b]; return 0; } ```
by Lemon___zqp @ 2024-02-16 21:29:28


|