QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190244#3669. Counting Stairstriplem5ds#WA 157ms132564kbC++231.4kb2023-09-28 15:54:422023-09-28 15:54:43

Judging History

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

  • [2023-09-28 15:54:43]
  • 评测
  • 测评结果:WA
  • 用时:157ms
  • 内存:132564kb
  • [2023-09-28 15:54:42]
  • 提交

answer

/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
//#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;

const int N = 5e5 + 5, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-7;
int dp[100005][320];

int solve(int n, int k) {
    if (n == 0)return 1;
    if (n < 0 || k == 0)return 0;
    int &ret = dp[n][k];
    if (~ret)return ret;
    return ret = (solve(n - k, k) + solve(n, k - 1)) % MOD;
}

void doWork() {

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i * i <= n; i++) {
        if ((n - i * i) & 1 ^ 1) {
            ans = (ans + solve((n - i * i) / 2, i)) % MOD;
        }
    }
    cout << ans << '\n';

}

int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    memset(dp, -1, sizeof dp);

    int t = 1;
    cin >> t;
    while (t--) {
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 128600kb

input:

4
3
5
17
25

output:

1
1
5
12

result:

ok 4 number(s): "1 1 5 12"

Test #2:

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

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
0
1
1
1
1
1
2
2
2

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 8ms
memory: 128668kb

input:

100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

output:

1
0
1
1
1
1
1
2
2
2
2
3
3
3
4
5
5
5
6
7
8
8
9
11
12
12
14
16
17
18
20
23
25
26
29
33
35
37
41
46
49
52
57
63
68
72
78
87
93
98
107
117
125
133
144
157
168
178
192
209
223
236
255
276
294
312
335
361
385
408
437
471
501
530
568
609
647
686
732
784
833
881
939
1004
1065
1126
1199
1279
1355
1433
1523
1...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 12ms
memory: 128672kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:

1
0
1
1
1
1
1
2
2
2
2
3
3
3
4
5
5
5
6
7
8
8
9
11
12
12
14
16
17
18
20
23
25
26
29
33
35
37
41
46
49
52
57
63
68
72
78
87
93
98
107
117
125
133
144
157
168
178
192
209
223
236
255
276
294
312
335
361
385
408
437
471
501
530
568
609
647
686
732
784
833
881
939
1004
1065
1126
1199
1279
1355
1433
1523
1...

result:

ok 1000 numbers

Test #5:

score: 0
Accepted
time: 4ms
memory: 128608kb

input:

10000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
10...

output:

1
0
1
1
1
1
1
2
2
2
2
3
3
3
4
5
5
5
6
7
8
8
9
11
12
12
14
16
17
18
20
23
25
26
29
33
35
37
41
46
49
52
57
63
68
72
78
87
93
98
107
117
125
133
144
157
168
178
192
209
223
236
255
276
294
312
335
361
385
408
437
471
501
530
568
609
647
686
732
784
833
881
939
1004
1065
1126
1199
1279
1355
1433
1523
1...

result:

ok 10000 numbers

Test #6:

score: -100
Wrong Answer
time: 157ms
memory: 132564kb

input:

10000
100001
100002
100003
100004
100005
100006
100007
100008
100009
100010
100011
100012
100013
100014
100015
100016
100017
100018
100019
100020
100021
100022
100023
100024
100025
100026
100027
100028
100029
100030
100031
100032
100033
100034
100035
100036
100037
100038
100039
100040
100041
100042
...

output:

901658944
373412979
159838772
93352400
534560307
831057100
811670865
57705550
645906893
768727288
921975397
932394471
197972981
716834849
61170927
235262457
913754883
472024596
615251594
387910217
785833767
195540737
309658819
706652518
523139486
162434523
809498786
501651788
870551965
958200438
298...

result:

wrong answer 3045th numbers differ - expected: '666873352', found: '666873351'