QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#263509#7526. Credit CardsMikhail#AC ✓49ms18992kbC++17984b2023-11-24 22:03:162023-11-24 22:03:16

Judging History

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

  • [2023-11-24 22:03:16]
  • 评测
  • 测评结果:AC
  • 用时:49ms
  • 内存:18992kb
  • [2023-11-24 22:03:16]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define cheat ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fe first
#define se second
#define int long long

using namespace std;

struct tripple{
    int a;
    int b;
    int c;
};


signed main(){
    int n;
    cin >> n;
    vector<int> sqr(n+1);
    for(int i=1;i<n+1;++i){
        sqr[i]=i*i;
    }
    vector<tripple> ans;
    ans.reserve(n/3);
    int a=(n-1)/3+1;
    int b=n-1;
    int c=n;
    while(a>1){
        while(sqr[c]-sqr[b]<=sqr[a]){
            --b;
        }
        int dif=c-b;
        for(int i=0;i<dif;++i){
            ans.push_back({a-i,b-i,c-i});
        }
        a-=dif;
        c=b-dif;
        b=c-1;
    }
    cout << (n-1)/3 << "\n";
    for(auto& x : ans){
        cout << x.a << " " << x.b << " " << x.c << "\n";
    }

}

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

详细

Test #1:

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

input:

3

output:

0

result:

ok OK 0 triangles!

Test #2:

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

input:

4

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #3:

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

input:

9

output:

2
3 8 9
2 6 7

result:

ok OK 2 triangles!

Test #4:

score: 0
Accepted
time: 49ms
memory: 18992kb

input:

1000000

output:

333333
333334 942808 1000000
333333 942807 999999
333332 942806 999998
333331 942805 999997
333330 942804 999996
333329 942803 999995
333328 942802 999994
333327 942801 999993
333326 942800 999992
333325 942799 999991
333324 942798 999990
333323 942797 999989
333322 942796 999988
333321 942795 99998...

result:

ok OK 333333 triangles!

Test #5:

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

input:

1

output:

0

result:

ok OK 0 triangles!

Test #6:

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

input:

2

output:

0

result:

ok OK 0 triangles!

Test #7:

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

input:

5

output:

1
2 4 5

result:

ok OK 1 triangles!

Test #8:

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

input:

6

output:

1
2 5 6

result:

ok OK 1 triangles!

Test #9:

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

input:

7

output:

2
3 6 7
2 4 5

result:

ok OK 2 triangles!

Test #10:

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

input:

8

output:

2
3 7 8
2 5 6

result:

ok OK 2 triangles!

Test #11:

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

input:

10

output:

3
4 9 10
3 7 8
2 5 6

result:

ok OK 3 triangles!

Test #12:

score: 0
Accepted
time: 26ms
memory: 12856kb

input:

621316

output:

207105
207106 585782 621316
207105 585781 621315
207104 585780 621314
207103 585779 621313
207102 585778 621312
207101 585777 621311
207100 585776 621310
207099 585775 621309
207098 585774 621308
207097 585773 621307
207096 585772 621306
207095 585771 621305
207094 585770 621304
207093 585769 621303...

result:

ok OK 207105 triangles!

Test #13:

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

input:

713171

output:

237723
237724 672383 713171
237723 672382 713170
237722 672381 713169
237721 672380 713168
237720 672379 713167
237719 672378 713166
237718 672377 713165
237717 672376 713164
237716 672375 713163
237715 672374 713162
237714 672373 713161
237713 672372 713160
237712 672371 713159
237711 672370 713158...

result:

ok OK 237723 triangles!

Test #14:

score: 0
Accepted
time: 39ms
memory: 15932kb

input:

825609

output:

275202
275203 778391 825609
275202 778390 825608
275201 778389 825607
275200 778388 825606
275199 778387 825605
275198 778386 825604
275197 778385 825603
275196 778384 825602
275195 778383 825601
275194 778382 825600
275193 778381 825599
275192 778380 825598
275191 778379 825597
275190 778378 825596...

result:

ok OK 275202 triangles!

Test #15:

score: 0
Accepted
time: 36ms
memory: 15296kb

input:

782282

output:

260760
260761 737542 782282
260760 737541 782281
260759 737540 782280
260758 737539 782279
260757 737538 782278
260756 737537 782277
260755 737536 782276
260754 737535 782275
260753 737534 782274
260752 737533 782273
260751 737532 782272
260750 737531 782271
260749 737530 782270
260748 737529 782269...

result:

ok OK 260760 triangles!

Test #16:

score: 0
Accepted
time: 9ms
memory: 5512kb

input:

148128

output:

49375
49376 139656 148128
49375 139655 148127
49374 139654 148126
49373 139653 148125
49372 139652 148124
49371 139651 148123
49370 139650 148122
49369 139649 148121
49368 139648 148120
49367 139647 148119
49366 139646 148118
49365 139645 148117
49364 139644 148116
49363 139643 148115
49362 139642 1...

result:

ok OK 49375 triangles!

Test #17:

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

input:

681282

output:

227093
227094 642318 681282
227093 642317 681281
227092 642316 681280
227091 642315 681279
227090 642314 681278
227089 642313 681277
227088 642312 681276
227087 642311 681275
227086 642310 681274
227085 642309 681273
227084 642308 681272
227083 642307 681271
227082 642306 681270
227081 642305 681269...

result:

ok OK 227093 triangles!

Test #18:

score: 0
Accepted
time: 37ms
memory: 15512kb

input:

798547

output:

266182
266183 752877 798547
266182 752876 798546
266181 752875 798545
266180 752874 798544
266179 752873 798543
266178 752872 798542
266177 752871 798541
266176 752870 798540
266175 752869 798539
266174 752868 798538
266173 752867 798537
266172 752866 798536
266171 752865 798535
266170 752864 798534...

result:

ok OK 266182 triangles!

Test #19:

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

input:

349290

output:

116429
116430 329313 349290
116429 329312 349289
116428 329311 349288
116427 329310 349287
116426 329309 349286
116425 329308 349285
116424 329307 349284
116423 329306 349283
116422 329305 349282
116421 329304 349281
116420 329303 349280
116419 329302 349279
116418 329301 349278
116417 329300 349277...

result:

ok OK 116429 triangles!

Test #20:

score: 0
Accepted
time: 15ms
memory: 8036kb

input:

317275

output:

105758
105759 299129 317275
105758 299128 317274
105757 299127 317273
105756 299126 317272
105755 299125 317271
105754 299124 317270
105753 299123 317269
105752 299122 317268
105751 299121 317267
105750 299120 317266
105749 299119 317265
105748 299118 317264
105747 299117 317263
105746 299116 317262...

result:

ok OK 105758 triangles!

Test #21:

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

input:

100000

output:

33333
33334 94280 100000
33333 94279 99999
33332 94278 99998
33331 94277 99997
33330 94276 99996
33329 94275 99995
33328 94274 99994
33327 94273 99993
33326 94272 99992
33325 94271 99991
33324 94270 99990
33323 94269 99989
33322 94268 99988
33321 94267 99987
33320 94266 99986
33319 94265 99985
33318...

result:

ok OK 33333 triangles!

Test #22:

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

input:

83568

output:

27855
27856 78788 83568
27855 78787 83567
27854 78786 83566
27853 78785 83565
27852 78784 83564
27851 78783 83563
27850 78782 83562
27849 78781 83561
27848 78780 83560
27847 78779 83559
27846 78778 83558
27845 78777 83557
27844 78776 83556
27843 78775 83555
27842 78774 83554
27841 78773 83553
27840 ...

result:

ok OK 27855 triangles!

Test #23:

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

input:

41476

output:

13825
13826 39103 41476
13825 39102 41475
13824 39101 41474
13823 39100 41473
13822 39099 41472
13821 39098 41471
13820 39097 41470
13819 39096 41469
13818 39095 41468
13817 39094 41467
13816 39093 41466
13815 39092 41465
13814 39091 41464
13813 39090 41463
13812 39089 41462
13811 39088 41461
13810 ...

result:

ok OK 13825 triangles!

Test #24:

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

input:

61028

output:

20342
20343 57537 61028
20342 57536 61027
20341 57535 61026
20340 57534 61025
20339 57533 61024
20338 57532 61023
20337 57531 61022
20336 57530 61021
20335 57529 61020
20334 57528 61019
20333 57527 61018
20332 57526 61017
20331 57525 61016
20330 57524 61015
20329 57523 61014
20328 57522 61013
20327 ...

result:

ok OK 20342 triangles!

Test #25:

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

input:

34231

output:

11410
11411 32273 34231
11410 32272 34230
11409 32271 34229
11408 32270 34228
11407 32269 34227
11406 32268 34226
11405 32267 34225
11404 32266 34224
11403 32265 34223
11402 32264 34222
11401 32263 34221
11400 32262 34220
11399 32261 34219
11398 32260 34218
11397 32259 34217
11396 32258 34216
11395 ...

result:

ok OK 11410 triangles!

Test #26:

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

input:

10000

output:

3333
3334 9427 10000
3333 9426 9999
3332 9425 9998
3331 9424 9997
3330 9423 9996
3329 9422 9995
3328 9421 9994
3327 9420 9993
3326 9419 9992
3325 9418 9991
3324 9417 9990
3323 9416 9989
3322 9415 9988
3321 9414 9987
3320 9413 9986
3319 9412 9985
3318 9411 9984
3317 9410 9983
3316 9409 9982
3315 9408...

result:

ok OK 3333 triangles!

Test #27:

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

input:

8370

output:

2789
2790 7891 8370
2789 7890 8369
2788 7889 8368
2787 7888 8367
2786 7887 8366
2785 7886 8365
2784 7885 8364
2783 7884 8363
2782 7883 8362
2781 7882 8361
2780 7881 8360
2779 7880 8359
2778 7879 8358
2777 7878 8357
2776 7877 8356
2775 7876 8355
2774 7875 8354
2773 7874 8353
2772 7873 8352
2771 7872 ...

result:

ok OK 2789 triangles!

Test #28:

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

input:

5858

output:

1952
1953 5522 5858
1952 5521 5857
1951 5520 5856
1950 5519 5855
1949 5518 5854
1948 5517 5853
1947 5516 5852
1946 5515 5851
1945 5514 5850
1944 5513 5849
1943 5512 5848
1942 5511 5847
1941 5510 5846
1940 5509 5845
1939 5508 5844
1938 5507 5843
1937 5506 5842
1936 5505 5841
1935 5504 5840
1934 5503 ...

result:

ok OK 1952 triangles!

Test #29:

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

input:

688

output:

229
230 648 688
229 647 687
228 646 686
227 645 685
226 644 684
225 643 683
224 642 682
223 641 681
222 640 680
221 639 679
220 638 678
219 637 677
218 636 676
217 635 675
216 634 674
215 633 673
214 632 672
213 631 671
212 630 670
211 629 669
210 628 668
209 627 667
208 626 666
207 625 665
206 624 ...

result:

ok OK 229 triangles!

Test #30:

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

input:

6480

output:

2159
2160 6109 6480
2159 6108 6479
2158 6107 6478
2157 6106 6477
2156 6105 6476
2155 6104 6475
2154 6103 6474
2153 6102 6473
2152 6101 6472
2151 6100 6471
2150 6099 6470
2149 6098 6469
2148 6097 6468
2147 6096 6467
2146 6095 6466
2145 6094 6465
2144 6093 6464
2143 6092 6463
2142 6091 6462
2141 6090 ...

result:

ok OK 2159 triangles!

Test #31:

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

input:

1000

output:

333
334 942 1000
333 941 999
332 940 998
331 939 997
330 938 996
329 937 995
328 936 994
327 935 993
326 934 992
325 933 991
324 932 990
323 931 989
322 930 988
321 929 987
320 928 986
319 927 985
318 926 984
317 925 983
316 924 982
315 923 981
314 922 980
313 921 979
312 920 978
311 919 977
310 918...

result:

ok OK 333 triangles!

Test #32:

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

input:

491

output:

163
164 462 491
163 461 490
162 460 489
161 459 488
160 458 487
159 457 486
158 456 485
157 455 484
156 454 483
155 453 482
154 452 481
153 451 480
152 450 479
151 449 478
150 448 477
149 447 476
148 446 475
147 445 474
146 444 473
145 443 472
144 442 471
143 441 470
142 440 469
141 439 468
140 438 ...

result:

ok OK 163 triangles!

Test #33:

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

input:

667

output:

222
223 628 667
222 627 666
221 626 665
220 625 664
219 624 663
218 623 662
217 622 661
216 621 660
215 620 659
214 619 658
213 618 657
212 617 656
211 616 655
210 615 654
209 614 653
208 613 652
207 612 651
206 611 650
205 610 649
204 609 648
203 608 647
202 607 646
201 606 645
200 605 644
199 604 ...

result:

ok OK 222 triangles!

Test #34:

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

input:

63

output:

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

result:

ok OK 20 triangles!

Test #35:

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

input:

682

output:

227
228 642 682
227 641 681
226 640 680
225 639 679
224 638 678
223 637 677
222 636 676
221 635 675
220 634 674
219 633 673
218 632 672
217 631 671
216 630 670
215 629 669
214 628 668
213 627 667
212 626 666
211 625 665
210 624 664
209 623 663
208 622 662
207 621 661
206 620 660
205 619 659
204 618 ...

result:

ok OK 227 triangles!

Test #36:

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

input:

100

output:

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

result:

ok OK 33 triangles!

Test #37:

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

input:

38

output:

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

result:

ok OK 12 triangles!

Test #38:

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

input:

167

output:

55
56 157 167
55 156 166
54 155 165
53 154 164
52 153 163
51 152 162
50 151 161
49 150 160
48 149 159
47 148 158
46 139 147
45 138 146
44 137 145
43 136 144
42 135 143
41 134 142
40 133 141
39 132 140
38 125 131
37 124 130
36 123 129
35 122 128
34 121 127
33 120 126
32 114 119
31 113 118
30 112 117
...

result:

ok OK 55 triangles!

Test #39:

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

input:

34

output:

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

result:

ok OK 11 triangles!