QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309188#7526. Credit Cards8BQube#AC ✓33ms10764kbC++201.8kb2024-01-20 15:32:442024-01-20 15:32:45

Judging History

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

  • [2024-01-20 15:32:45]
  • 评测
  • 测评结果:AC
  • 用时:33ms
  • 内存:10764kb
  • [2024-01-20 15:32:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

struct Tuple {
    int x, y, z;
    void check() const {
        assert(x < y && y < z);
        assert(x + y > z);
        assert((ll)x * x + (ll)y * y < (ll)z * z);
    }
};

vector<Tuple> solve(int n) {
    if (n <= 3) return {};
    while (n % 3 != 1) --n;
    if (n == 7) {
        vector<Tuple> result;
        result.push_back({2, 4, 5});
        result.push_back({3, 6, 7});
        return result;
    }
    if (n == 10) {
        vector<Tuple> result;
        result.push_back({2, 4, 5});
        result.push_back({3, 8, 9});
        result.push_back({6, 7, 10});
        return result;
    }
    if (n == 19) {
        vector<Tuple> result;
        result.push_back({2, 3, 4});
        result.push_back({5, 6, 8});
        result.push_back({7, 11, 15});
        result.push_back({9, 14, 17});
        result.push_back({12, 13, 18});
        result.push_back({10, 16, 19});
        return result;
    }
    auto result = solve(n / 3);
    int req = n / 3 - (int)result.size();
    for (int i = req - 1; i >= 0; --i) {
        result.push_back({n - i - req * 2, n - i - req, n - i});
    }
    return result;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    auto ans = solve(n);
    cout << ans.size() << endl;
    // set<int> st;
    for (const auto &tri : ans) {
        tri.check();
        cout << tri.x << ' ' << tri.y << ' ' << tri.z << '\n';
        /*
        st.insert(tri.x);
        st.insert(tri.y);
        st.insert(tri.z);
        */
    }
    // assert(st.size() == ans.size() * 3);
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3584kb

input:

3

output:

0

result:

ok OK 0 triangles!

Test #2:

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

input:

4

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #3:

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

input:

9

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #4:

score: 0
Accepted
time: 33ms
memory: 10124kb

input:

1000000

output:

333333
2 3 4
5 9 13
6 10 14
7 11 15
8 12 16
17 28 39
18 29 40
19 30 41
20 31 42
21 32 43
22 33 44
23 34 45
24 35 46
25 36 47
26 37 48
27 38 49
50 84 118
51 85 119
52 86 120
53 87 121
54 88 122
55 89 123
56 90 124
57 91 125
58 92 126
59 93 127
60 94 128
61 95 129
62 96 130
63 97 131
64 98 132
65 99 1...

result:

ok OK 333333 triangles!

Test #5:

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

input:

1

output:

0

result:

ok OK 0 triangles!

Test #6:

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

input:

2

output:

0

result:

ok OK 0 triangles!

Test #7:

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

input:

5

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #8:

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

input:

6

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #9:

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

input:

7

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #10:

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

input:

8

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #11:

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

input:

10

output:

3
2 4 5
3 8 9
6 7 10

result:

ok OK 3 triangles!

Test #12:

score: 0
Accepted
time: 24ms
memory: 6988kb

input:

621316

output:

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

result:

ok OK 207105 triangles!

Test #13:

score: 0
Accepted
time: 25ms
memory: 6208kb

input:

713171

output:

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

result:

ok OK 237723 triangles!

Test #14:

score: 0
Accepted
time: 31ms
memory: 10152kb

input:

825609

output:

275202
2 3 4
5 8 11
6 9 12
7 10 13
14 23 32
15 24 33
16 25 34
17 26 35
18 27 36
19 28 37
20 29 38
21 30 39
22 31 40
41 69 97
42 70 98
43 71 99
44 72 100
45 73 101
46 74 102
47 75 103
48 76 104
49 77 105
50 78 106
51 79 107
52 80 108
53 81 109
54 82 110
55 83 111
56 84 112
57 85 113
58 86 114
59 87 1...

result:

ok OK 275202 triangles!

Test #15:

score: 0
Accepted
time: 28ms
memory: 6212kb

input:

782282

output:

260760
2 4 5
3 8 9
6 7 10
11 20 29
12 21 30
13 22 31
14 23 32
15 24 33
16 25 34
17 26 35
18 27 36
19 28 37
38 65 92
39 66 93
40 67 94
41 68 95
42 69 96
43 70 97
44 71 98
45 72 99
46 73 100
47 74 101
48 75 102
49 76 103
50 77 104
51 78 105
52 79 106
53 80 107
54 81 108
55 82 109
56 83 110
57 84 111
5...

result:

ok OK 260760 triangles!

Test #16:

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

input:

148128

output:

49375
2 4 5
3 6 7
8 13 18
9 14 19
10 15 20
11 16 21
12 17 22
23 38 53
24 39 54
25 40 55
26 41 56
27 42 57
28 43 58
29 44 59
30 45 60
31 46 61
32 47 62
33 48 63
34 49 64
35 50 65
36 51 66
37 52 67
68 113 158
69 114 159
70 115 160
71 116 161
72 117 162
73 118 163
74 119 164
75 120 165
76 121 166
77 12...

result:

ok OK 49375 triangles!

Test #17:

score: 0
Accepted
time: 24ms
memory: 6348kb

input:

681282

output:

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

result:

ok OK 227093 triangles!

Test #18:

score: 0
Accepted
time: 25ms
memory: 10764kb

input:

798547

output:

266182
2 3 4
5 8 11
6 9 12
7 10 13
14 23 32
15 24 33
16 25 34
17 26 35
18 27 36
19 28 37
20 29 38
21 30 39
22 31 40
41 68 95
42 69 96
43 70 97
44 71 98
45 72 99
46 73 100
47 74 101
48 75 102
49 76 103
50 77 104
51 78 105
52 79 106
53 80 107
54 81 108
55 82 109
56 83 110
57 84 111
58 85 112
59 86 113...

result:

ok OK 266182 triangles!

Test #19:

score: 0
Accepted
time: 10ms
memory: 4768kb

input:

349290

output:

116429
2 3 4
5 9 13
6 10 14
7 11 15
8 12 16
17 29 41
18 30 42
19 31 43
20 32 44
21 33 45
22 34 46
23 35 47
24 36 48
25 37 49
26 38 50
27 39 51
28 40 52
53 88 123
54 89 124
55 90 125
56 91 126
57 92 127
58 93 128
59 94 129
60 95 130
61 96 131
62 97 132
63 98 133
64 99 134
65 100 135
66 101 136
67 102...

result:

ok OK 116429 triangles!

Test #20:

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

input:

317275

output:

105758
2 3 4
5 8 11
6 9 12
7 10 13
14 25 36
15 26 37
16 27 38
17 28 39
18 29 40
19 30 41
20 31 42
21 32 43
22 33 44
23 34 45
24 35 46
47 79 111
48 80 112
49 81 113
50 82 114
51 83 115
52 84 116
53 85 117
54 86 118
55 87 119
56 88 120
57 89 121
58 90 122
59 91 123
60 92 124
61 93 125
62 94 126
63 95 ...

result:

ok OK 105758 triangles!

Test #21:

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

input:

100000

output:

33333
2 3 4
5 8 11
6 9 12
7 10 13
14 24 34
15 25 35
16 26 36
17 27 37
18 28 38
19 29 39
20 30 40
21 31 41
22 32 42
23 33 43
44 75 106
45 76 107
46 77 108
47 78 109
48 79 110
49 80 111
50 81 112
51 82 113
52 83 114
53 84 115
54 85 116
55 86 117
56 87 118
57 88 119
58 89 120
59 90 121
60 91 122
61 92 ...

result:

ok OK 33333 triangles!

Test #22:

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

input:

83568

output:

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

result:

ok OK 27855 triangles!

Test #23:

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

input:

41476

output:

13825
2 3 4
5 9 13
6 10 14
7 11 15
8 12 16
17 30 43
18 31 44
19 32 45
20 33 46
21 34 47
22 35 48
23 36 49
24 37 50
25 38 51
26 39 52
27 40 53
28 41 54
29 42 55
56 94 132
57 95 133
58 96 134
59 97 135
60 98 136
61 99 137
62 100 138
63 101 139
64 102 140
65 103 141
66 104 142
67 105 143
68 106 144
69 ...

result:

ok OK 13825 triangles!

Test #24:

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

input:

61028

output:

20342
2 4 5
3 6 7
8 14 20
9 15 21
10 16 22
11 17 23
12 18 24
13 19 25
26 45 64
27 46 65
28 47 66
29 48 67
30 49 68
31 50 69
32 51 70
33 52 71
34 53 72
35 54 73
36 55 74
37 56 75
38 57 76
39 58 77
40 59 78
41 60 79
42 61 80
43 62 81
44 63 82
83 139 195
84 140 196
85 141 197
86 142 198
87 143 199
88 1...

result:

ok OK 20342 triangles!

Test #25:

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

input:

34231

output:

11410
2 3 4
5 8 11
6 9 12
7 10 13
14 25 36
15 26 37
16 27 38
17 28 39
18 29 40
19 30 41
20 31 42
21 32 43
22 33 44
23 34 45
24 35 46
47 78 109
48 79 110
49 80 111
50 81 112
51 82 113
52 83 114
53 84 115
54 85 116
55 86 117
56 87 118
57 88 119
58 89 120
59 90 121
60 91 122
61 92 123
62 93 124
63 94 1...

result:

ok OK 11410 triangles!

Test #26:

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

input:

10000

output:

3333
2 3 4
5 8 11
6 9 12
7 10 13
14 23 32
15 24 33
16 25 34
17 26 35
18 27 36
19 28 37
20 29 38
21 30 39
22 31 40
41 68 95
42 69 96
43 70 97
44 71 98
45 72 99
46 73 100
47 74 101
48 75 102
49 76 103
50 77 104
51 78 105
52 79 106
53 80 107
54 81 108
55 82 109
56 83 110
57 84 111
58 85 112
59 86 113
6...

result:

ok OK 3333 triangles!

Test #27:

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

input:

8370

output:

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

result:

ok OK 2789 triangles!

Test #28:

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

input:

5858

output:

1952
2 4 5
3 6 7
8 13 18
9 14 19
10 15 20
11 16 21
12 17 22
23 39 55
24 40 56
25 41 57
26 42 58
27 43 59
28 44 60
29 45 61
30 46 62
31 47 63
32 48 64
33 49 65
34 50 66
35 51 67
36 52 68
37 53 69
38 54 70
71 119 167
72 120 168
73 121 169
74 122 170
75 123 171
76 124 172
77 125 173
78 126 174
79 127 1...

result:

ok OK 1952 triangles!

Test #29:

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

input:

688

output:

229
2 4 5
3 6 7
8 14 20
9 15 21
10 16 22
11 17 23
12 18 24
13 19 25
26 43 60
27 44 61
28 45 62
29 46 63
30 47 64
31 48 65
32 49 66
33 50 67
34 51 68
35 52 69
36 53 70
37 54 71
38 55 72
39 56 73
40 57 74
41 58 75
42 59 76
77 128 179
78 129 180
79 130 181
80 131 182
81 132 183
82 133 184
83 134 185
84...

result:

ok OK 229 triangles!

Test #30:

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

input:

6480

output:

2159
2 4 5
3 6 7
8 14 20
9 15 21
10 16 22
11 17 23
12 18 24
13 19 25
26 44 62
27 45 63
28 46 64
29 47 65
30 48 66
31 49 67
32 50 68
33 51 69
34 52 70
35 53 71
36 54 72
37 55 73
38 56 74
39 57 75
40 58 76
41 59 77
42 60 78
43 61 79
80 133 186
81 134 187
82 135 188
83 136 189
84 137 190
85 138 191
86 ...

result:

ok OK 2159 triangles!

Test #31:

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

input:

1000

output:

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

result:

ok OK 333 triangles!

Test #32:

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

input:

491

output:

163
2 3 4
5 9 13
6 10 14
7 11 15
8 12 16
17 29 41
18 30 42
19 31 43
20 32 44
21 33 45
22 34 46
23 35 47
24 36 48
25 37 49
26 38 50
27 39 51
28 40 52
53 90 127
54 91 128
55 92 129
56 93 130
57 94 131
58 95 132
59 96 133
60 97 134
61 98 135
62 99 136
63 100 137
64 101 138
65 102 139
66 103 140
67 104 ...

result:

ok OK 163 triangles!

Test #33:

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

input:

667

output:

222
2 4 5
3 6 7
8 13 18
9 14 19
10 15 20
11 16 21
12 17 22
23 40 57
24 41 58
25 42 59
26 43 60
27 44 61
28 45 62
29 46 63
30 47 64
31 48 65
32 49 66
33 50 67
34 51 68
35 52 69
36 53 70
37 54 71
38 55 72
39 56 73
74 123 172
75 124 173
76 125 174
77 126 175
78 127 176
79 128 177
80 129 178
81 130 179
...

result:

ok OK 222 triangles!

Test #34:

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

input:

63

output:

20
2 3 4
5 6 8
7 11 15
9 14 17
12 13 18
10 16 19
20 34 48
21 35 49
22 36 50
23 37 51
24 38 52
25 39 53
26 40 54
27 41 55
28 42 56
29 43 57
30 44 58
31 45 59
32 46 60
33 47 61

result:

ok OK 20 triangles!

Test #35:

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

input:

682

output:

227
2 4 5
3 6 7
8 13 18
9 14 19
10 15 20
11 16 21
12 17 22
23 40 57
24 41 58
25 42 59
26 43 60
27 44 61
28 45 62
29 46 63
30 47 64
31 48 65
32 49 66
33 50 67
34 51 68
35 52 69
36 53 70
37 54 71
38 55 72
39 56 73
74 125 176
75 126 177
76 127 178
77 128 179
78 129 180
79 130 181
80 131 182
81 132 183
...

result:

ok OK 227 triangles!

Test #36:

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

input:

100

output:

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

result:

ok OK 33 triangles!

Test #37:

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

input:

38

output:

12
2 4 5
3 8 9
6 7 10
11 20 29
12 21 30
13 22 31
14 23 32
15 24 33
16 25 34
17 26 35
18 27 36
19 28 37

result:

ok OK 12 triangles!

Test #38:

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

input:

167

output:

55
2 3 4
5 9 13
6 10 14
7 11 15
8 12 16
17 30 43
18 31 44
19 32 45
20 33 46
21 34 47
22 35 48
23 36 49
24 37 50
25 38 51
26 39 52
27 40 53
28 41 54
29 42 55
56 93 130
57 94 131
58 95 132
59 96 133
60 97 134
61 98 135
62 99 136
63 100 137
64 101 138
65 102 139
66 103 140
67 104 141
68 105 142
69 106 ...

result:

ok OK 55 triangles!

Test #39:

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

input:

34

output:

11
2 4 5
3 8 9
6 7 10
11 19 27
12 20 28
13 21 29
14 22 30
15 23 31
16 24 32
17 25 33
18 26 34

result:

ok OK 11 triangles!