QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562077 | #7526. Credit Cards | ucup-team052# | AC ✓ | 678ms | 7664kb | C++23 | 607b | 2024-09-13 14:51:32 | 2024-09-13 14:51:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int used[N];
int n;
int main() {
scanf("%d", &n);
while (n % 3 != 1) --n;
for (int i = 2; i <= n / 3 + 1; i++) used[i] = 1;
int mx = n;
printf("%d\n", n / 3);
for (int i = n / 3 + 1; i >= 2; i--) {
while (used[mx]) --mx;
int j = sqrt(1ll * mx * mx - 1ll * i * i) + 3;
j = min(j, mx - 1);
while (1ll * mx * mx - 1ll * j * j <= 1ll * i * i || used[j]) --j;
assert(i + j > mx && 1ll * i * i + 1ll * j * j < 1ll * mx * mx);
printf("%d %d %d\n", i, j, mx);
used[j] = used[mx] = 1;
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
3
output:
0
result:
ok OK 0 triangles!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
4
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
9
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #4:
score: 0
Accepted
time: 678ms
memory: 7664kb
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: 0ms
memory: 3812kb
input:
1
output:
0
result:
ok OK 0 triangles!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
2
output:
0
result:
ok OK 0 triangles!
Test #7:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
5
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #8:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
6
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #9:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
7
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
8
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #11:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
10
output:
3 4 9 10 3 7 8 2 5 6
result:
ok OK 3 triangles!
Test #12:
score: 0
Accepted
time: 269ms
memory: 6184kb
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: 342ms
memory: 6548kb
input:
713171
output:
237723 237724 672382 713170 237723 672381 713169 237722 672380 713168 237721 672379 713167 237720 672378 713166 237719 672377 713165 237718 672376 713164 237717 672375 713163 237716 672374 713162 237715 672373 713161 237714 672372 713160 237713 672371 713159 237712 672370 713158 237711 672369 713157...
result:
ok OK 237723 triangles!
Test #14:
score: 0
Accepted
time: 465ms
memory: 7120kb
input:
825609
output:
275202 275203 778389 825607 275202 778388 825606 275201 778387 825605 275200 778386 825604 275199 778385 825603 275198 778384 825602 275197 778383 825601 275196 778382 825600 275195 778381 825599 275194 778380 825598 275193 778379 825597 275192 778378 825596 275191 778377 825595 275190 778376 825594...
result:
ok OK 275202 triangles!
Test #15:
score: 0
Accepted
time: 416ms
memory: 6860kb
input:
782282
output:
260760 260761 737541 782281 260760 737540 782280 260759 737539 782279 260758 737538 782278 260757 737537 782277 260756 737536 782276 260755 737535 782275 260754 737534 782274 260753 737533 782273 260752 737532 782272 260751 737531 782271 260750 737530 782270 260749 737529 782269 260748 737528 782268...
result:
ok OK 260760 triangles!
Test #16:
score: 0
Accepted
time: 21ms
memory: 4428kb
input:
148128
output:
49375 49376 139654 148126 49375 139653 148125 49374 139652 148124 49373 139651 148123 49372 139650 148122 49371 139649 148121 49370 139648 148120 49369 139647 148119 49368 139646 148118 49367 139645 148117 49366 139644 148116 49365 139643 148115 49364 139642 148114 49363 139641 148113 49362 139640 1...
result:
ok OK 49375 triangles!
Test #17:
score: 0
Accepted
time: 324ms
memory: 6516kb
input:
681282
output:
227093 227094 642316 681280 227093 642315 681279 227092 642314 681278 227091 642313 681277 227090 642312 681276 227089 642311 681275 227088 642310 681274 227087 642309 681273 227086 642308 681272 227085 642307 681271 227084 642306 681270 227083 642305 681269 227082 642304 681268 227081 642303 681267...
result:
ok OK 227093 triangles!
Test #18:
score: 0
Accepted
time: 441ms
memory: 6948kb
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: 90ms
memory: 5172kb
input:
349290
output:
116429 116430 329311 349288 116429 329310 349287 116428 329309 349286 116427 329308 349285 116426 329307 349284 116425 329306 349283 116424 329305 349282 116423 329304 349281 116422 329303 349280 116421 329302 349279 116420 329301 349278 116419 329300 349277 116418 329299 349276 116417 329298 349275...
result:
ok OK 116429 triangles!
Test #20:
score: 0
Accepted
time: 79ms
memory: 5188kb
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: 11ms
memory: 4360kb
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: 9ms
memory: 4132kb
input:
83568
output:
27855 27856 78786 83566 27855 78785 83565 27854 78784 83564 27853 78783 83563 27852 78782 83562 27851 78781 83561 27850 78780 83560 27849 78779 83559 27848 78778 83558 27847 78777 83557 27846 78776 83556 27845 78775 83555 27844 78774 83554 27843 78773 83553 27842 78772 83552 27841 78771 83551 27840 ...
result:
ok OK 27855 triangles!
Test #23:
score: 0
Accepted
time: 3ms
memory: 4084kb
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: 6ms
memory: 4068kb
input:
61028
output:
20342 20343 57536 61027 20342 57535 61026 20341 57534 61025 20340 57533 61024 20339 57532 61023 20338 57531 61022 20337 57530 61021 20336 57529 61020 20335 57528 61019 20334 57527 61018 20333 57526 61017 20332 57525 61016 20331 57524 61015 20330 57523 61014 20329 57522 61013 20328 57521 61012 20327 ...
result:
ok OK 20342 triangles!
Test #25:
score: 0
Accepted
time: 3ms
memory: 4104kb
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: 3800kb
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: 3848kb
input:
8370
output:
2789 2790 7889 8368 2789 7888 8367 2788 7887 8366 2787 7886 8365 2786 7885 8364 2785 7884 8363 2784 7883 8362 2783 7882 8361 2782 7881 8360 2781 7880 8359 2780 7879 8358 2779 7878 8357 2778 7877 8356 2777 7876 8355 2776 7875 8354 2775 7874 8353 2774 7873 8352 2773 7872 8351 2772 7871 8350 2771 7870 ...
result:
ok OK 2789 triangles!
Test #28:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
5858
output:
1952 1953 5521 5857 1952 5520 5856 1951 5519 5855 1950 5518 5854 1949 5517 5853 1948 5516 5852 1947 5515 5851 1946 5514 5850 1945 5513 5849 1944 5512 5848 1943 5511 5847 1942 5510 5846 1941 5509 5845 1940 5508 5844 1939 5507 5843 1938 5506 5842 1937 5505 5841 1936 5504 5840 1935 5503 5839 1934 5502 ...
result:
ok OK 1952 triangles!
Test #29:
score: 0
Accepted
time: 0ms
memory: 3892kb
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: 3908kb
input:
6480
output:
2159 2160 6107 6478 2159 6106 6477 2158 6105 6476 2157 6104 6475 2156 6103 6474 2155 6102 6473 2154 6101 6472 2153 6100 6471 2152 6099 6470 2151 6098 6469 2150 6097 6468 2149 6096 6467 2148 6095 6466 2147 6094 6465 2146 6093 6464 2145 6092 6463 2144 6091 6462 2143 6090 6461 2142 6089 6460 2141 6088 ...
result:
ok OK 2159 triangles!
Test #31:
score: 0
Accepted
time: 0ms
memory: 3976kb
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: 3916kb
input:
491
output:
163 164 461 490 163 460 489 162 459 488 161 458 487 160 457 486 159 456 485 158 455 484 157 454 483 156 453 482 155 452 481 154 451 480 153 450 479 152 449 478 151 448 477 150 447 476 149 446 475 148 445 474 147 444 473 146 443 472 145 442 471 144 441 470 143 440 469 142 439 468 141 438 467 140 437 ...
result:
ok OK 163 triangles!
Test #33:
score: 0
Accepted
time: 0ms
memory: 3916kb
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: 3764kb
input:
63
output:
20 21 57 61 20 56 60 19 55 59 18 54 58 17 50 53 16 49 52 15 48 51 14 44 47 13 43 46 12 42 45 11 39 41 10 38 40 9 35 37 8 34 36 7 32 33 6 30 31 5 28 29 4 26 27 3 24 25 2 22 23
result:
ok OK 20 triangles!
Test #35:
score: 0
Accepted
time: 0ms
memory: 3896kb
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: 0ms
memory: 3816kb
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: 3764kb
input:
38
output:
12 13 34 37 12 33 36 11 32 35 10 29 31 9 28 30 8 25 27 7 24 26 6 22 23 5 20 21 4 18 19 3 16 17 2 14 15
result:
ok OK 12 triangles!
Test #38:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
167
output:
55 56 156 166 55 155 165 54 154 164 53 153 163 52 152 162 51 151 161 50 150 160 49 149 159 48 148 158 47 147 157 46 138 146 45 137 145 44 136 144 43 135 143 42 134 142 41 133 141 40 132 140 39 131 139 38 124 130 37 123 129 36 122 128 35 121 127 34 120 126 33 119 125 32 113 118 31 112 117 30 111 116 ...
result:
ok OK 55 triangles!
Test #39:
score: 0
Accepted
time: 0ms
memory: 3852kb
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!