QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61758 | #1807. Distribute the Bars | Constant | AC ✓ | 12ms | 3732kb | C++14 | 919b | 2022-11-14 19:03:24 | 2022-11-14 19:03:25 |
Judging History
answer
#include<bits/stdc++.h>
#define N 200005
#define ll long long
using namespace std;
int n,d=2,t,cnt;
inline int read()
{
int s=0,w=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
while(isdigit(ch))s=s*10+(ch^48),ch=getchar();
return s*w;
}
int check(int x)
{
for(int i=2;i*i<=x;i++)
{
if(x%i==0) return 0;
}
return 1;
}
int main()
{
n=read();
if(check(n)) cout<<"-1";
else
{
while(n%d) d++;
if(d==2)
{
printf("%d\n",n/2);
for(int i=1;i<=n/2;i++) printf("2 %d %d\n",2*i-1,2*n-2*i+1);
}
else
{
printf("%d\n",d);
t=n/d;cnt=0;
for(int i=0;i<=d-1;i++)
{
printf("%d ",t);
for(int j=0;j<=d-1;j++) printf("%d ",2*(j*d+(i+j)%d+1)-1);
for(int j=0;j<=(t-d)/2-1;j++)
{
cnt++;
printf("%d %d ",2*(d*d+cnt)-1,2*(n-cnt+1)-1);
}
printf("\n");
}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 2ms
memory: 3336kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3324kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
1659
output:
3 553 1 9 17 19 3317 21 3315 23 3313 25 3311 27 3309 29 3307 31 3305 33 3303 35 3301 37 3299 39 3297 41 3295 43 3293 45 3291 47 3289 49 3287 51 3285 53 3283 55 3281 57 3279 59 3277 61 3275 63 3273 65 3271 67 3269 69 3267 71 3265 73 3263 75 3261 77 3259 79 3257 81 3255 83 3253 85 3251 87 3249 89 3247...
result:
ok OK (3 groups)
Test #5:
score: 0
Accepted
time: 2ms
memory: 3444kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: 0
Accepted
time: 2ms
memory: 3724kb
input:
458
output:
229 2 1 915 2 3 913 2 5 911 2 7 909 2 9 907 2 11 905 2 13 903 2 15 901 2 17 899 2 19 897 2 21 895 2 23 893 2 25 891 2 27 889 2 29 887 2 31 885 2 33 883 2 35 881 2 37 879 2 39 877 2 41 875 2 43 873 2 45 871 2 47 869 2 49 867 2 51 865 2 53 863 2 55 861 2 57 859 2 59 857 2 61 855 2 63 853 2 65 851 2 67...
result:
ok OK (229 groups)
Test #7:
score: 0
Accepted
time: 1ms
memory: 3380kb
input:
5
output:
-1
result:
ok OK (impossible)
Test #8:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
9
output:
3 3 1 9 17 3 3 11 13 3 5 7 15
result:
ok OK (3 groups)
Test #9:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
25
output:
5 5 1 13 25 37 49 5 3 15 27 39 41 5 5 17 29 31 43 5 7 19 21 33 45 5 9 11 23 35 47
result:
ok OK (5 groups)
Test #10:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
143
output:
11 13 1 25 49 73 97 121 145 169 193 217 241 243 285 13 3 27 51 75 99 123 147 171 195 219 221 245 283 13 5 29 53 77 101 125 149 173 197 199 223 247 281 13 7 31 55 79 103 127 151 175 177 201 225 249 279 13 9 33 57 81 105 129 153 155 179 203 227 251 277 13 11 35 59 83 107 131 133 157 181 205 229 2...
result:
ok OK (11 groups)
Test #11:
score: 0
Accepted
time: 12ms
memory: 3524kb
input:
85849
output:
293 293 1 589 1177 1765 2353 2941 3529 4117 4705 5293 5881 6469 7057 7645 8233 8821 9409 9997 10585 11173 11761 12349 12937 13525 14113 14701 15289 15877 16465 17053 17641 18229 18817 19405 19993 20581 21169 21757 22345 22933 23521 24109 24697 25285 25873 26461 27049 27637 28225 28813 29401 29989 30...
result:
ok OK (293 groups)
Test #12:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
99991
output:
-1
result:
ok OK (impossible)
Test #13:
score: 0
Accepted
time: 8ms
memory: 3512kb
input:
99997
output:
19 5263 1 41 81 121 161 201 241 281 321 361 401 441 481 521 561 601 641 681 721 723 199993 725 199991 727 199989 729 199987 731 199985 733 199983 735 199981 737 199979 739 199977 741 199975 743 199973 745 199971 747 199969 749 199967 751 199965 753 199963 755 199961 757 199959 759 199957 761 199955 ...
result:
ok OK (19 groups)
Test #14:
score: 0
Accepted
time: 6ms
memory: 3636kb
input:
100000
output:
50000 2 1 199999 2 3 199997 2 5 199995 2 7 199993 2 9 199991 2 11 199989 2 13 199987 2 15 199985 2 17 199983 2 19 199981 2 21 199979 2 23 199977 2 25 199975 2 27 199973 2 29 199971 2 31 199969 2 33 199967 2 35 199965 2 37 199963 2 39 199961 2 41 199959 2 43 199957 2 45 199955 2 47 199953 2 49 199951...
result:
ok OK (50000 groups)
Test #15:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
28454
output:
14227 2 1 56907 2 3 56905 2 5 56903 2 7 56901 2 9 56899 2 11 56897 2 13 56895 2 15 56893 2 17 56891 2 19 56889 2 21 56887 2 23 56885 2 25 56883 2 27 56881 2 29 56879 2 31 56877 2 33 56875 2 35 56873 2 37 56871 2 39 56869 2 41 56867 2 43 56865 2 45 56863 2 47 56861 2 49 56859 2 51 56857 2 53 56855 2 ...
result:
ok OK (14227 groups)
Test #16:
score: 0
Accepted
time: 8ms
memory: 3524kb
input:
64338
output:
32169 2 1 128675 2 3 128673 2 5 128671 2 7 128669 2 9 128667 2 11 128665 2 13 128663 2 15 128661 2 17 128659 2 19 128657 2 21 128655 2 23 128653 2 25 128651 2 27 128649 2 29 128647 2 31 128645 2 33 128643 2 35 128641 2 37 128639 2 39 128637 2 41 128635 2 43 128633 2 45 128631 2 47 128629 2 49 128627...
result:
ok OK (32169 groups)
Test #17:
score: 0
Accepted
time: 11ms
memory: 3456kb
input:
88078
output:
44039 2 1 176155 2 3 176153 2 5 176151 2 7 176149 2 9 176147 2 11 176145 2 13 176143 2 15 176141 2 17 176139 2 19 176137 2 21 176135 2 23 176133 2 25 176131 2 27 176129 2 29 176127 2 31 176125 2 33 176123 2 35 176121 2 37 176119 2 39 176117 2 41 176115 2 43 176113 2 45 176111 2 47 176109 2 49 176107...
result:
ok OK (44039 groups)
Test #18:
score: 0
Accepted
time: 2ms
memory: 3448kb
input:
16831
output:
-1
result:
ok OK (impossible)
Test #19:
score: 0
Accepted
time: 2ms
memory: 3728kb
input:
10880
output:
5440 2 1 21759 2 3 21757 2 5 21755 2 7 21753 2 9 21751 2 11 21749 2 13 21747 2 15 21745 2 17 21743 2 19 21741 2 21 21739 2 23 21737 2 25 21735 2 27 21733 2 29 21731 2 31 21729 2 33 21727 2 35 21725 2 37 21723 2 39 21721 2 41 21719 2 43 21717 2 45 21715 2 47 21713 2 49 21711 2 51 21709 2 53 21707 2 5...
result:
ok OK (5440 groups)
Test #20:
score: 0
Accepted
time: 2ms
memory: 3236kb
input:
28979
output:
-1
result:
ok OK (impossible)
Test #21:
score: 0
Accepted
time: 0ms
memory: 3232kb
input:
20173
output:
-1
result:
ok OK (impossible)
Test #22:
score: 0
Accepted
time: 2ms
memory: 3340kb
input:
78401
output:
-1
result:
ok OK (impossible)
Test #23:
score: 0
Accepted
time: 2ms
memory: 3236kb
input:
52067
output:
-1
result:
ok OK (impossible)
Test #24:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
94727
output:
-1
result:
ok OK (impossible)
Test #25:
score: 0
Accepted
time: 6ms
memory: 3664kb
input:
35657
output:
181 197 1 365 729 1093 1457 1821 2185 2549 2913 3277 3641 4005 4369 4733 5097 5461 5825 6189 6553 6917 7281 7645 8009 8373 8737 9101 9465 9829 10193 10557 10921 11285 11649 12013 12377 12741 13105 13469 13833 14197 14561 14925 15289 15653 16017 16381 16745 17109 17473 17837 18201 18565 18929 19293 1...
result:
ok OK (181 groups)
Test #26:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
41449
output:
181 229 1 365 729 1093 1457 1821 2185 2549 2913 3277 3641 4005 4369 4733 5097 5461 5825 6189 6553 6917 7281 7645 8009 8373 8737 9101 9465 9829 10193 10557 10921 11285 11649 12013 12377 12741 13105 13469 13833 14197 14561 14925 15289 15653 16017 16381 16745 17109 17473 17837 18201 18565 18929 19293 1...
result:
ok OK (181 groups)
Test #27:
score: 0
Accepted
time: 3ms
memory: 3660kb
input:
7367
output:
53 139 1 109 217 325 433 541 649 757 865 973 1081 1189 1297 1405 1513 1621 1729 1837 1945 2053 2161 2269 2377 2485 2593 2701 2809 2917 3025 3133 3241 3349 3457 3565 3673 3781 3889 3997 4105 4213 4321 4429 4537 4645 4753 4861 4969 5077 5185 5293 5401 5509 5617 5619 14733 5621 14731 5623 14729 5625 14...
result:
ok OK (53 groups)
Test #28:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
12191
output:
73 167 1 149 297 445 593 741 889 1037 1185 1333 1481 1629 1777 1925 2073 2221 2369 2517 2665 2813 2961 3109 3257 3405 3553 3701 3849 3997 4145 4293 4441 4589 4737 4885 5033 5181 5329 5477 5625 5773 5921 6069 6217 6365 6513 6661 6809 6957 7105 7253 7401 7549 7697 7845 7993 8141 8289 8437 8585 8733 88...
result:
ok OK (73 groups)
Test #29:
score: 0
Accepted
time: 6ms
memory: 3460kb
input:
43847
output:
163 269 1 329 657 985 1313 1641 1969 2297 2625 2953 3281 3609 3937 4265 4593 4921 5249 5577 5905 6233 6561 6889 7217 7545 7873 8201 8529 8857 9185 9513 9841 10169 10497 10825 11153 11481 11809 12137 12465 12793 13121 13449 13777 14105 14433 14761 15089 15417 15745 16073 16401 16729 17057 17385 17713...
result:
ok OK (163 groups)
Test #30:
score: 0
Accepted
time: 4ms
memory: 3660kb
input:
20819
output:
109 191 1 221 441 661 881 1101 1321 1541 1761 1981 2201 2421 2641 2861 3081 3301 3521 3741 3961 4181 4401 4621 4841 5061 5281 5501 5721 5941 6161 6381 6601 6821 7041 7261 7481 7701 7921 8141 8361 8581 8801 9021 9241 9461 9681 9901 10121 10341 10561 10781 11001 11221 11441 11661 11881 12101 12321 125...
result:
ok OK (109 groups)
Test #31:
score: 0
Accepted
time: 3ms
memory: 3664kb
input:
9943
output:
61 163 1 125 249 373 497 621 745 869 993 1117 1241 1365 1489 1613 1737 1861 1985 2109 2233 2357 2481 2605 2729 2853 2977 3101 3225 3349 3473 3597 3721 3845 3969 4093 4217 4341 4465 4589 4713 4837 4961 5085 5209 5333 5457 5581 5705 5829 5953 6077 6201 6325 6449 6573 6697 6821 6945 7069 7193 7317 7441...
result:
ok OK (61 groups)
Test #32:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
1369
output:
37 37 1 77 153 229 305 381 457 533 609 685 761 837 913 989 1065 1141 1217 1293 1369 1445 1521 1597 1673 1749 1825 1901 1977 2053 2129 2205 2281 2357 2433 2509 2585 2661 2737 37 3 79 155 231 307 383 459 535 611 687 763 839 915 991 1067 1143 1219 1295 1371 1447 1523 1599 1675 1751 1827 1903 1979 2055...
result:
ok OK (37 groups)
Test #33:
score: 0
Accepted
time: 3ms
memory: 3500kb
input:
6241
output:
79 79 1 161 321 481 641 801 961 1121 1281 1441 1601 1761 1921 2081 2241 2401 2561 2721 2881 3041 3201 3361 3521 3681 3841 4001 4161 4321 4481 4641 4801 4961 5121 5281 5441 5601 5761 5921 6081 6241 6401 6561 6721 6881 7041 7201 7361 7521 7681 7841 8001 8161 8321 8481 8641 8801 8961 9121 9281 9441 960...
result:
ok OK (79 groups)
Test #34:
score: 0
Accepted
time: 2ms
memory: 3728kb
input:
841
output:
29 29 1 61 121 181 241 301 361 421 481 541 601 661 721 781 841 901 961 1021 1081 1141 1201 1261 1321 1381 1441 1501 1561 1621 1681 29 3 63 123 183 243 303 363 423 483 543 603 663 723 783 843 903 963 1023 1083 1143 1203 1263 1323 1383 1443 1503 1563 1623 1625 29 5 65 125 185 245 305 365 425 485 545...
result:
ok OK (29 groups)
Test #35:
score: 0
Accepted
time: 9ms
memory: 3732kb
input:
69169
output:
263 263 1 529 1057 1585 2113 2641 3169 3697 4225 4753 5281 5809 6337 6865 7393 7921 8449 8977 9505 10033 10561 11089 11617 12145 12673 13201 13729 14257 14785 15313 15841 16369 16897 17425 17953 18481 19009 19537 20065 20593 21121 21649 22177 22705 23233 23761 24289 24817 25345 25873 26401 26929 274...
result:
ok OK (263 groups)
Test #36:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
121
output:
11 11 1 25 49 73 97 121 145 169 193 217 241 11 3 27 51 75 99 123 147 171 195 219 221 11 5 29 53 77 101 125 149 173 197 199 223 11 7 31 55 79 103 127 151 175 177 201 225 11 9 33 57 81 105 129 153 155 179 203 227 11 11 35 59 83 107 131 133 157 181 205 229 11 13 37 61 85 109 111 135 159 183 207 2...
result:
ok OK (11 groups)