QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176323 | #7225. The Kirakira Cycle | ucup-team004# | AC ✓ | 1120ms | 211152kb | C++20 | 1.6kb | 2023-09-11 15:16:29 | 2023-09-11 15:16:30 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 10000;
constexpr int M = N * (N - 1) / 2;
int f[M + 1];
std::bitset<M + 1> isprime;
std::bitset<M + 1> vis;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
if (n == 1) {
std::cout << 1 << "\n";
return 0;
}
int m = n * (n - 1) / 2;
for (int i = 2; i <= m; i++) {
isprime[i] = 1;
}
for (int i = 2; i <= n; i++) {
if (isprime[i]) {
for (int j = i * i; j <= m; j += i) {
isprime[j] = false;
}
}
}
for (int i = 1; i <= n; i++) {
f[i] = i;
}
for (int i = 2; i <= m; i++) {
if (isprime[i]) {
for (int j = 1; j <= m / i; j++) {
f[i * j] += f[j];
}
}
}
for (int i = 1; i <= m; i++) {
f[i] += f[i - 1];
}
for (int i = 0; i <= m; i++) {
f[i] = i * n - f[i];
}
int ans = 0;
for (int i = 0; i <= m; i++) {
if (vis[i]) {
continue;
}
int j = i;
int len = 0;
while (!vis[j]) {
vis[j] = true;
j = f[j];
len++;
}
int k = j;
for (int l = 1; l <= len; l++) {
k = f[k];
if (k == j) {
ans = std::max(ans, l);
break;
}
}
}
std::cout << ans << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5772kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7812kb
input:
10
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 7752kb
input:
43
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 7768kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 7752kb
input:
4
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 1ms
memory: 7756kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 1ms
memory: 7808kb
input:
6
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 1ms
memory: 7820kb
input:
7
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 1ms
memory: 7752kb
input:
8
output:
3
result:
ok 1 number(s): "3"
Test #11:
score: 0
Accepted
time: 1ms
memory: 7652kb
input:
9
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
11
output:
7
result:
ok 1 number(s): "7"
Test #13:
score: 0
Accepted
time: 1ms
memory: 7764kb
input:
13
output:
6
result:
ok 1 number(s): "6"
Test #14:
score: 0
Accepted
time: 1ms
memory: 7756kb
input:
17
output:
4
result:
ok 1 number(s): "4"
Test #15:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
19
output:
5
result:
ok 1 number(s): "5"
Test #16:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
23
output:
3
result:
ok 1 number(s): "3"
Test #17:
score: 0
Accepted
time: 1ms
memory: 7768kb
input:
29
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 0
Accepted
time: 0ms
memory: 7752kb
input:
31
output:
13
result:
ok 1 number(s): "13"
Test #19:
score: 0
Accepted
time: 1ms
memory: 7768kb
input:
37
output:
5
result:
ok 1 number(s): "5"
Test #20:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
41
output:
21
result:
ok 1 number(s): "21"
Test #21:
score: 0
Accepted
time: 0ms
memory: 7756kb
input:
60
output:
8
result:
ok 1 number(s): "8"
Test #22:
score: 0
Accepted
time: 1ms
memory: 7768kb
input:
100
output:
11
result:
ok 1 number(s): "11"
Test #23:
score: 0
Accepted
time: 1ms
memory: 7736kb
input:
105
output:
41
result:
ok 1 number(s): "41"
Test #24:
score: 0
Accepted
time: 1ms
memory: 7812kb
input:
128
output:
31
result:
ok 1 number(s): "31"
Test #25:
score: 0
Accepted
time: 0ms
memory: 7752kb
input:
130
output:
25
result:
ok 1 number(s): "25"
Test #26:
score: 0
Accepted
time: 0ms
memory: 7736kb
input:
256
output:
52
result:
ok 1 number(s): "52"
Test #27:
score: 0
Accepted
time: 1ms
memory: 7772kb
input:
290
output:
15
result:
ok 1 number(s): "15"
Test #28:
score: 0
Accepted
time: 2ms
memory: 7704kb
input:
455
output:
104
result:
ok 1 number(s): "104"
Test #29:
score: 0
Accepted
time: 2ms
memory: 7768kb
input:
512
output:
45
result:
ok 1 number(s): "45"
Test #30:
score: 0
Accepted
time: 4ms
memory: 9776kb
input:
777
output:
35
result:
ok 1 number(s): "35"
Test #31:
score: 0
Accepted
time: 0ms
memory: 9820kb
input:
707
output:
175
result:
ok 1 number(s): "175"
Test #32:
score: 0
Accepted
time: 2ms
memory: 7836kb
input:
449
output:
13
result:
ok 1 number(s): "13"
Test #33:
score: 0
Accepted
time: 0ms
memory: 7708kb
input:
573
output:
168
result:
ok 1 number(s): "168"
Test #34:
score: 0
Accepted
time: 5ms
memory: 7796kb
input:
858
output:
49
result:
ok 1 number(s): "49"
Test #35:
score: 0
Accepted
time: 1ms
memory: 7748kb
input:
230
output:
58
result:
ok 1 number(s): "58"
Test #36:
score: 0
Accepted
time: 6ms
memory: 9820kb
input:
972
output:
117
result:
ok 1 number(s): "117"
Test #37:
score: 0
Accepted
time: 5ms
memory: 9916kb
input:
844
output:
47
result:
ok 1 number(s): "47"
Test #38:
score: 0
Accepted
time: 2ms
memory: 7828kb
input:
378
output:
37
result:
ok 1 number(s): "37"
Test #39:
score: 0
Accepted
time: 0ms
memory: 7780kb
input:
423
output:
49
result:
ok 1 number(s): "49"
Test #40:
score: 0
Accepted
time: 1ms
memory: 7692kb
input:
209
output:
20
result:
ok 1 number(s): "20"
Test #41:
score: 0
Accepted
time: 283ms
memory: 75228kb
input:
5645
output:
338
result:
ok 1 number(s): "338"
Test #42:
score: 0
Accepted
time: 30ms
memory: 16208kb
input:
2034
output:
249
result:
ok 1 number(s): "249"
Test #43:
score: 0
Accepted
time: 343ms
memory: 85904kb
input:
6163
output:
206
result:
ok 1 number(s): "206"
Test #44:
score: 0
Accepted
time: 395ms
memory: 96292kb
input:
6422
output:
346
result:
ok 1 number(s): "346"
Test #45:
score: 0
Accepted
time: 17ms
memory: 11992kb
input:
1550
output:
40
result:
ok 1 number(s): "40"
Test #46:
score: 0
Accepted
time: 473ms
memory: 106936kb
input:
6940
output:
674
result:
ok 1 number(s): "674"
Test #47:
score: 0
Accepted
time: 29ms
memory: 16132kb
input:
2068
output:
157
result:
ok 1 number(s): "157"
Test #48:
score: 0
Accepted
time: 361ms
memory: 85884kb
input:
6197
output:
594
result:
ok 1 number(s): "594"
Test #49:
score: 0
Accepted
time: 406ms
memory: 94284kb
input:
6456
output:
913
result:
ok 1 number(s): "913"
Test #50:
score: 0
Accepted
time: 831ms
memory: 166064kb
input:
8776
output:
423
result:
ok 1 number(s): "423"
Test #51:
score: 0
Accepted
time: 103ms
memory: 37348kb
input:
3904
output:
281
result:
ok 1 number(s): "281"
Test #52:
score: 0
Accepted
time: 121ms
memory: 45688kb
input:
4163
output:
230
result:
ok 1 number(s): "230"
Test #53:
score: 0
Accepted
time: 130ms
memory: 45872kb
input:
4422
output:
631
result:
ok 1 number(s): "631"
Test #54:
score: 0
Accepted
time: 162ms
memory: 54200kb
input:
4681
output:
95
result:
ok 1 number(s): "95"
Test #55:
score: 0
Accepted
time: 824ms
memory: 168140kb
input:
8810
output:
835
result:
ok 1 number(s): "835"
Test #56:
score: 0
Accepted
time: 100ms
memory: 39416kb
input:
3938
output:
350
result:
ok 1 number(s): "350"
Test #57:
score: 0
Accepted
time: 951ms
memory: 186128kb
input:
9328
output:
373
result:
ok 1 number(s): "373"
Test #58:
score: 0
Accepted
time: 125ms
memory: 49860kb
input:
4456
output:
932
result:
ok 1 number(s): "932"
Test #59:
score: 0
Accepted
time: 155ms
memory: 56192kb
input:
4715
output:
476
result:
ok 1 number(s): "476"
Test #60:
score: 0
Accepted
time: 591ms
memory: 130084kb
input:
7633
output:
591
result:
ok 1 number(s): "591"
Test #61:
score: 0
Accepted
time: 45ms
memory: 22612kb
input:
2762
output:
263
result:
ok 1 number(s): "263"
Test #62:
score: 0
Accepted
time: 679ms
memory: 146976kb
input:
8152
output:
465
result:
ok 1 number(s): "465"
Test #63:
score: 0
Accepted
time: 63ms
memory: 30920kb
input:
3280
output:
157
result:
ok 1 number(s): "157"
Test #64:
score: 0
Accepted
time: 79ms
memory: 35076kb
input:
3539
output:
79
result:
ok 1 number(s): "79"
Test #65:
score: 0
Accepted
time: 605ms
memory: 128084kb
input:
7668
output:
905
result:
ok 1 number(s): "905"
Test #66:
score: 0
Accepted
time: 651ms
memory: 138640kb
input:
7927
output:
357
result:
ok 1 number(s): "357"
Test #67:
score: 0
Accepted
time: 700ms
memory: 147020kb
input:
8186
output:
543
result:
ok 1 number(s): "543"
Test #68:
score: 0
Accepted
time: 68ms
memory: 28900kb
input:
3314
output:
306
result:
ok 1 number(s): "306"
Test #69:
score: 0
Accepted
time: 85ms
memory: 33112kb
input:
3573
output:
69
result:
ok 1 number(s): "69"
Test #70:
score: 0
Accepted
time: 460ms
memory: 104856kb
input:
6873
output:
667
result:
ok 1 number(s): "667"
Test #71:
score: 0
Accepted
time: 28ms
memory: 16192kb
input:
2001
output:
134
result:
ok 1 number(s): "134"
Test #72:
score: 0
Accepted
time: 553ms
memory: 121684kb
input:
7391
output:
477
result:
ok 1 number(s): "477"
Test #73:
score: 0
Accepted
time: 40ms
memory: 20492kb
input:
2519
output:
267
result:
ok 1 number(s): "267"
Test #74:
score: 0
Accepted
time: 49ms
memory: 26708kb
input:
2778
output:
162
result:
ok 1 number(s): "162"
Test #75:
score: 0
Accepted
time: 62ms
memory: 26712kb
input:
3037
output:
282
result:
ok 1 number(s): "282"
Test #76:
score: 0
Accepted
time: 69ms
memory: 28900kb
input:
3296
output:
458
result:
ok 1 number(s): "458"
Test #77:
score: 0
Accepted
time: 548ms
memory: 123820kb
input:
7426
output:
214
result:
ok 1 number(s): "214"
Test #78:
score: 0
Accepted
time: 38ms
memory: 24596kb
input:
2554
output:
102
result:
ok 1 number(s): "102"
Test #79:
score: 0
Accepted
time: 662ms
memory: 138588kb
input:
7944
output:
283
result:
ok 1 number(s): "283"
Test #80:
score: 0
Accepted
time: 333ms
memory: 87912kb
input:
6113
output:
121
result:
ok 1 number(s): "121"
Test #81:
score: 0
Accepted
time: 1096ms
memory: 211152kb
input:
10000
output:
917
result:
ok 1 number(s): "917"
Test #82:
score: 0
Accepted
time: 1100ms
memory: 211116kb
input:
9999
output:
470
result:
ok 1 number(s): "470"
Test #83:
score: 0
Accepted
time: 1118ms
memory: 211072kb
input:
9998
output:
1552
result:
ok 1 number(s): "1552"
Test #84:
score: 0
Accepted
time: 1095ms
memory: 211036kb
input:
9997
output:
538
result:
ok 1 number(s): "538"
Test #85:
score: 0
Accepted
time: 1085ms
memory: 210936kb
input:
9996
output:
193
result:
ok 1 number(s): "193"
Test #86:
score: 0
Accepted
time: 1120ms
memory: 210896kb
input:
9995
output:
624
result:
ok 1 number(s): "624"
Test #87:
score: 0
Accepted
time: 1110ms
memory: 210860kb
input:
9994
output:
481
result:
ok 1 number(s): "481"
Test #88:
score: 0
Accepted
time: 1115ms
memory: 210884kb
input:
9993
output:
617
result:
ok 1 number(s): "617"
Test #89:
score: 0
Accepted
time: 1105ms
memory: 210848kb
input:
9992
output:
433
result:
ok 1 number(s): "433"
Test #90:
score: 0
Accepted
time: 1093ms
memory: 210872kb
input:
9991
output:
425
result:
ok 1 number(s): "425"
Test #91:
score: 0
Accepted
time: 1099ms
memory: 210704kb
input:
9990
output:
509
result:
ok 1 number(s): "509"
Test #92:
score: 0
Accepted
time: 1084ms
memory: 210728kb
input:
9989
output:
808
result:
ok 1 number(s): "808"
Test #93:
score: 0
Accepted
time: 1111ms
memory: 211076kb
input:
9988
output:
734
result:
ok 1 number(s): "734"
Test #94:
score: 0
Accepted
time: 1096ms
memory: 210660kb
input:
9987
output:
922
result:
ok 1 number(s): "922"
Test #95:
score: 0
Accepted
time: 1086ms
memory: 210548kb
input:
9986
output:
1252
result:
ok 1 number(s): "1252"
Test #96:
score: 0
Accepted
time: 1100ms
memory: 210672kb
input:
9985
output:
378
result:
ok 1 number(s): "378"
Test #97:
score: 0
Accepted
time: 1095ms
memory: 210488kb
input:
9984
output:
472
result:
ok 1 number(s): "472"
Test #98:
score: 0
Accepted
time: 1097ms
memory: 210484kb
input:
9983
output:
363
result:
ok 1 number(s): "363"
Test #99:
score: 0
Accepted
time: 1099ms
memory: 210516kb
input:
9982
output:
1121
result:
ok 1 number(s): "1121"
Test #100:
score: 0
Accepted
time: 1098ms
memory: 210856kb
input:
9981
output:
261
result:
ok 1 number(s): "261"
Test #101:
score: 0
Accepted
time: 1092ms
memory: 211096kb
input:
9980
output:
228
result:
ok 1 number(s): "228"
Test #102:
score: 0
Accepted
time: 19ms
memory: 14040kb
input:
1811
output:
2
result:
ok 1 number(s): "2"
Test #103:
score: 0
Accepted
time: 277ms
memory: 69068kb
input:
5598
output:
14
result:
ok 1 number(s): "14"
Test #104:
score: 0
Accepted
time: 42ms
memory: 20408kb
input:
2466
output:
33
result:
ok 1 number(s): "33"
Extra Test:
score: 0
Extra Test Passed