QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73152#4812. Counting SequenceAcestarRE 112ms173292kbC++14567b2023-01-22 14:35:192023-01-22 14:35:19

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-22 14:35:19]
  • 评测
  • 测评结果:RE
  • 用时:112ms
  • 内存:173292kb
  • [2023-01-22 14:35:19]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = 3e5 + 5;
const int mod = 998244353;

int add(int x) {return x < mod ? x : x - mod;}

int s, c;
ll f[5000][5000];

int main()
{
    cin >> s >> c;
    for(int i = 0; i <= s; i++) f[i][i] = 1;
    for(int i = 1; i <= s; i++)
        for(int j = 1; j < i; j++)
            f[i][j] = (f[i][j] + f[i - j][j - 1] + f[i - j][j + 1] * c % mod) % mod;
    int ans = 0;
    for(int i = 1; i <= s; i++) ans = add(ans + f[s][i]);
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3368kb

input:

5 3

output:

8

result:

ok 1 number(s): "8"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3520kb

input:

1 0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 16ms
memory: 81336kb

input:

2022 39

output:

273239559

result:

ok 1 number(s): "273239559"

Test #4:

score: 0
Accepted
time: 2ms
memory: 3224kb

input:

1 998244352

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3448kb

input:

1 12345678

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 2ms
memory: 5372kb

input:

20 998998

output:

643731701

result:

ok 1 number(s): "643731701"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3416kb

input:

23 123

output:

947753998

result:

ok 1 number(s): "947753998"

Test #8:

score: 0
Accepted
time: 1ms
memory: 5504kb

input:

50 5555

output:

745339864

result:

ok 1 number(s): "745339864"

Test #9:

score: 0
Accepted
time: 2ms
memory: 5572kb

input:

60 6666

output:

690992218

result:

ok 1 number(s): "690992218"

Test #10:

score: 0
Accepted
time: 3ms
memory: 7588kb

input:

100 50

output:

169678588

result:

ok 1 number(s): "169678588"

Test #11:

score: 0
Accepted
time: 0ms
memory: 24072kb

input:

500 88888

output:

216149701

result:

ok 1 number(s): "216149701"

Test #12:

score: 0
Accepted
time: 5ms
memory: 42508kb

input:

1000 213456

output:

270989457

result:

ok 1 number(s): "270989457"

Test #13:

score: 0
Accepted
time: 21ms
memory: 83224kb

input:

2000 119988

output:

756425375

result:

ok 1 number(s): "756425375"

Test #14:

score: 0
Accepted
time: 46ms
memory: 120240kb

input:

3000 998244352

output:

71841227

result:

ok 1 number(s): "71841227"

Test #15:

score: 0
Accepted
time: 50ms
memory: 120272kb

input:

3000 555555555

output:

79880116

result:

ok 1 number(s): "79880116"

Test #16:

score: 0
Accepted
time: 112ms
memory: 173292kb

input:

4321 1234

output:

949603993

result:

ok 1 number(s): "949603993"

Test #17:

score: -100
Runtime Error

input:

5000 0

output:


result: