QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523745 | #6771. K-skip Permutation | zzz111 | AC ✓ | 40ms | 15020kb | C++20 | 1.0kb | 2024-08-18 17:21:14 | 2024-08-18 17:21:15 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define endl '\n'
#define fr(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define br(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
using namespace std;
const int N = 1e7 ;
int a[N];
int ans[N];
int cnt;
inline void solve()
{
int n, k;
cin >> n >> k;
if (k == 1)
{
for (int i = 1; i <= n - 1; i++)
cout << i << " ";
cout << n;
return;
}
fr(i, 1, n)
{
if(cnt == n)
break;
if (a[i])
continue;
ans[++cnt] = i;
a[i] = 1;
int tem = i;
while (tem + k <= n)
{
ans[++cnt] = tem + k;
tem += k;
a[tem + k] = 1;
}
}
for (int i = 1; i <= n - 1; i++)
{
cout << ans[i] << ' ';
}
cout << ans[n];
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
3 1
output:
1 2 3
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
7 3
output:
1 4 7 2 5 3 6
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
3 7
output:
1 2 3
result:
ok ok
Test #4:
score: 0
Accepted
time: 32ms
memory: 15020kb
input:
1000000 2
output:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...
result:
ok ok
Test #5:
score: 0
Accepted
time: 39ms
memory: 12784kb
input:
1000000 20
output:
1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341 361 381 401 421 441 461 481 501 521 541 561 581 601 621 641 661 681 701 721 741 761 781 801 821 841 861 881 901 921 941 961 981 1001 1021 1041 1061 1081 1101 1121 1141 1161 1181 1201 1221 1241 1261 1281 1301 1321 1341 1361 1381 1401 1...
result:
ok ok
Test #6:
score: 0
Accepted
time: 35ms
memory: 14532kb
input:
1000000 200
output:
1 201 401 601 801 1001 1201 1401 1601 1801 2001 2201 2401 2601 2801 3001 3201 3401 3601 3801 4001 4201 4401 4601 4801 5001 5201 5401 5601 5801 6001 6201 6401 6601 6801 7001 7201 7401 7601 7801 8001 8201 8401 8601 8801 9001 9201 9401 9601 9801 10001 10201 10401 10601 10801 11001 11201 11401 11601 118...
result:
ok ok
Test #7:
score: 0
Accepted
time: 35ms
memory: 14568kb
input:
1000000 2777
output:
1 2778 5555 8332 11109 13886 16663 19440 22217 24994 27771 30548 33325 36102 38879 41656 44433 47210 49987 52764 55541 58318 61095 63872 66649 69426 72203 74980 77757 80534 83311 86088 88865 91642 94419 97196 99973 102750 105527 108304 111081 113858 116635 119412 122189 124966 127743 130520 133297 1...
result:
ok ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
3 2
output:
1 3 2
result:
ok ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1000 499
output:
1 500 999 2 501 1000 3 502 4 503 5 504 6 505 7 506 8 507 9 508 10 509 11 510 12 511 13 512 14 513 15 514 16 515 17 516 18 517 19 518 20 519 21 520 22 521 23 522 24 523 25 524 26 525 27 526 28 527 29 528 30 529 31 530 32 531 33 532 34 533 35 534 36 535 37 536 38 537 39 538 40 539 41 540 42 541 43 542...
result:
ok ok
Test #10:
score: 0
Accepted
time: 37ms
memory: 14568kb
input:
1000000 999999
output:
1 1000000 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 ...
result:
ok ok
Test #11:
score: 0
Accepted
time: 36ms
memory: 13868kb
input:
1000000 464565
output:
1 464566 929131 2 464567 929132 3 464568 929133 4 464569 929134 5 464570 929135 6 464571 929136 7 464572 929137 8 464573 929138 9 464574 929139 10 464575 929140 11 464576 929141 12 464577 929142 13 464578 929143 14 464579 929144 15 464580 929145 16 464581 929146 17 464582 929147 18 464583 929148 19 ...
result:
ok ok
Test #12:
score: 0
Accepted
time: 40ms
memory: 13500kb
input:
1000000 29
output:
1 30 59 88 117 146 175 204 233 262 291 320 349 378 407 436 465 494 523 552 581 610 639 668 697 726 755 784 813 842 871 900 929 958 987 1016 1045 1074 1103 1132 1161 1190 1219 1248 1277 1306 1335 1364 1393 1422 1451 1480 1509 1538 1567 1596 1625 1654 1683 1712 1741 1770 1799 1828 1857 1886 1915 1944 ...
result:
ok ok
Test #13:
score: 0
Accepted
time: 28ms
memory: 12652kb
input:
978766 2123
output:
1 2124 4247 6370 8493 10616 12739 14862 16985 19108 21231 23354 25477 27600 29723 31846 33969 36092 38215 40338 42461 44584 46707 48830 50953 53076 55199 57322 59445 61568 63691 65814 67937 70060 72183 74306 76429 78552 80675 82798 84921 87044 89167 91290 93413 95536 97659 99782 101905 104028 106151...
result:
ok ok
Test #14:
score: 0
Accepted
time: 15ms
memory: 8912kb
input:
435453 234
output:
1 235 469 703 937 1171 1405 1639 1873 2107 2341 2575 2809 3043 3277 3511 3745 3979 4213 4447 4681 4915 5149 5383 5617 5851 6085 6319 6553 6787 7021 7255 7489 7723 7957 8191 8425 8659 8893 9127 9361 9595 9829 10063 10297 10531 10765 10999 11233 11467 11701 11935 12169 12403 12637 12871 13105 13339 13...
result:
ok ok
Test #15:
score: 0
Accepted
time: 3ms
memory: 4740kb
input:
133455 147
output:
1 148 295 442 589 736 883 1030 1177 1324 1471 1618 1765 1912 2059 2206 2353 2500 2647 2794 2941 3088 3235 3382 3529 3676 3823 3970 4117 4264 4411 4558 4705 4852 4999 5146 5293 5440 5587 5734 5881 6028 6175 6322 6469 6616 6763 6910 7057 7204 7351 7498 7645 7792 7939 8086 8233 8380 8527 8674 8821 8968...
result:
ok ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 6032kb
input:
34534 32
output:
1 33 65 97 129 161 193 225 257 289 321 353 385 417 449 481 513 545 577 609 641 673 705 737 769 801 833 865 897 929 961 993 1025 1057 1089 1121 1153 1185 1217 1249 1281 1313 1345 1377 1409 1441 1473 1505 1537 1569 1601 1633 1665 1697 1729 1761 1793 1825 1857 1889 1921 1953 1985 2017 2049 2081 2113 21...
result:
ok ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
1999 1001
output:
1 1002 2 1003 3 1004 4 1005 5 1006 6 1007 7 1008 8 1009 9 1010 10 1011 11 1012 12 1013 13 1014 14 1015 15 1016 16 1017 17 1018 18 1019 19 1020 20 1021 21 1022 22 1023 23 1024 24 1025 25 1026 26 1027 27 1028 28 1029 29 1030 30 1031 31 1032 32 1033 33 1034 34 1035 35 1036 36 1037 37 1038 38 1039 39 10...
result:
ok ok
Test #18:
score: 0
Accepted
time: 15ms
memory: 7952kb
input:
453435 3423
output:
1 3424 6847 10270 13693 17116 20539 23962 27385 30808 34231 37654 41077 44500 47923 51346 54769 58192 61615 65038 68461 71884 75307 78730 82153 85576 88999 92422 95845 99268 102691 106114 109537 112960 116383 119806 123229 126652 130075 133498 136921 140344 143767 147190 150613 154036 157459 160882 ...
result:
ok ok
Test #19:
score: 0
Accepted
time: 16ms
memory: 9808kb
input:
345345 342323
output:
1 342324 2 342325 3 342326 4 342327 5 342328 6 342329 7 342330 8 342331 9 342332 10 342333 11 342334 12 342335 13 342336 14 342337 15 342338 16 342339 17 342340 18 342341 19 342342 20 342343 21 342344 22 342345 23 342346 24 342347 25 342348 26 342349 27 342350 28 342351 29 342352 30 342353 31 342354...
result:
ok ok
Test #20:
score: 0
Accepted
time: 18ms
memory: 3692kb
input:
452354 1
output:
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 102 ...
result:
ok ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
4324 234
output:
1 235 469 703 937 1171 1405 1639 1873 2107 2341 2575 2809 3043 3277 3511 3745 3979 4213 2 236 470 704 938 1172 1406 1640 1874 2108 2342 2576 2810 3044 3278 3512 3746 3980 4214 3 237 471 705 939 1173 1407 1641 1875 2109 2343 2577 2811 3045 3279 3513 3747 3981 4215 4 238 472 706 940 1174 1408 1642 187...
result:
ok ok
Test #22:
score: 0
Accepted
time: 39ms
memory: 13340kb
input:
978787 2345
output:
1 2346 4691 7036 9381 11726 14071 16416 18761 21106 23451 25796 28141 30486 32831 35176 37521 39866 42211 44556 46901 49246 51591 53936 56281 58626 60971 63316 65661 68006 70351 72696 75041 77386 79731 82076 84421 86766 89111 91456 93801 96146 98491 100836 103181 105526 107871 110216 112561 114906 1...
result:
ok ok
Test #23:
score: 0
Accepted
time: 28ms
memory: 11244kb
input:
777777 1000000
output:
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 102 ...
result:
ok ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
1 1000000
output:
1
result:
ok ok