QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648131#7470. WBLTguosoun100 ✓812ms10392kbC++172.5kb2024-10-17 17:11:452024-10-17 17:11:45

Judging History

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

  • [2024-10-17 17:11:45]
  • 评测
  • 测评结果:100
  • 用时:812ms
  • 内存:10392kb
  • [2024-10-17 17:11:45]
  • 提交

answer

#include <bits/stdc++.h>
template <class T>
void chkmax(T &x, const T &y) {
  if (x < y) x = y;
}
using ull = unsigned long long;
const int N = 100100;

template <int N>
struct bitset {
  static const int B = 64;
  std::array<ull, (N - 1) / B + 2> a;
  bitset() : a() {}
  void set(int i) { a[i >> 6] |= 1ull << (i & 63); }
  void reset(int i) { a[i >> 6] &= ~(1ull << (i & 63)); }
  ull gets(int i) {
    if (i >= N) return 0;
    return a[i >> 6] >> (i & 63) |
           ((i & 63) ? a[(i >> 6) + 1] << (B - (i & 63)) : 0);
  }
  int calc(int k) {
    int ret = 0;
    for (int i = 0; i < k; i += B) {
      ull cur = -1;
      if (k - i < B) cur &= (1ull << (k - i)) - 1;
      for (int j = i, c = 1; cur &= gets(j); j += k, c++) chkmax(ret, c);
    }
    return ret;
  }
};

int main() {
  const int B = 10;
  std::cin.tie(0)->sync_with_stdio(0);
  int n, m;
  std::cin >> n;
  std::vector<int> a(n);
  for (auto &x : a) std::cin >> x;
  std::cin >> m;
  std::vector<int> ans(m);
  std::vector<std::tuple<int, int, int, int *>> q(m);
  for (int i = 0; auto &[l, r, b, it] : q) {
    std::cin >> l >> r >> b, l--, r--;
    it = &ans[i++];
  }
  std::sort(q.begin(), q.end(), [](auto x, auto y) -> bool {
    auto [l1, r1, b1, it1] = x;
    auto [l2, r2, b2, it2] = y;
    if (l1 / 400 == l2 / 400) return (r1 < r2) ^ ((l1 / 400) & 1);
    return l1 < l2;
  });
  for (int b = 1; b < B; b++) {
    std::vector<std::array<int, N>> cnt(b);
    std::vector<std::bitset<N>> vis(b);
    for (auto &t : vis) t.set();
    auto add = [&](int i) {
      if (!cnt[a[i] % b][a[i] / b]++) vis[a[i] % b][a[i] / b] = 0;
    };
    auto remove = [&](int i) {
      if (!--cnt[a[i] % b][a[i] / b]) vis[a[i] % b][a[i] / b] = 1;
    };
    int l = 1, r = 0;
    for (auto [ql, qr, qb, it] : q) {
      if (qb != b) continue;
      while (r < qr) add(++r);
      while (l > ql) add(--l);
      while (r > qr) remove(r--);
      while (l < ql) remove(l++);
      for (int i = 0; i < b; i++) {
        chkmax<int>(*it, vis[i]._Find_first());
      }
    }
  }
  std::array<int, N> cnt{};
  bitset<N> vis;
  auto add = [&](int i) {
    if (!cnt[a[i]]++) vis.set(a[i]);
  };
  auto remove = [&](int i) {
    if (!--cnt[a[i]]) vis.reset(a[i]);
  };
  int l = 1, r = 0;
  for (auto [ql, qr, qb, it] : q) {
    if (qb < B) continue;
    while (r < qr) add(++r);
    while (l > ql) add(--l);
    while (r > qr) remove(r--);
    while (l < ql) remove(l++);
    *it = vis.calc(qb);
  }
  for (int i : ans) std::cout << i << '\n';
}

详细

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 7ms
memory: 7076kb

input:

1000
233 991 831 426 140 881 289 287 957 886 561 109 305 469 961 577 683 593 277 601 181 255 100 997 161 619 632 413 987 811 357 635 99 809 888 511 945 881 261 434 851 311 21 641 508 701 661 158 696 560 577 501 951 786 909 238 546 573 617 236 270 705 786 353 651 296 353 720 261 429 855 176 977 57 50...

output:

3
3
2
4
4
0
3
2
2
2
2
2
1
4
2
2
3
3
2
2
5
3
1
2
2
2
2
1
3
3
2
3
1
3
5
2
0
4
2
1
5
2
2
2
2
2
2
2
2
2
2
6
1
3
2
1
2
2
1
0
0
2
2
2
3
2
1
3
2
2
2
3
2
4
0
2
2
2
3
3
2
2
0
2
3
2
2
2
4
1
2
2
4
3
2
2
5
3
2
2
1
1
2
2
2
6
3
2
1
2
3
1
1
0
3
3
2
2
2
1
2
2
2
3
3
3
2
4
3
2
1
5
2
4
2
1
1
2
2
3
2
2
2
3
3
2
2
1
2
2
...

result:

ok 1000 numbers

Subtask #2:

score: 30
Accepted

Test #2:

score: 30
Accepted
time: 102ms
memory: 10316kb

input:

100000
241 721 861 909 540 928 171 159 637 60 145 227 110 975 766 220 311 761 191 980 887 793 773 957 625 61 994 606 465 625 598 667 181 197 15 826 136 499 199 331 621 327 945 726 197 997 681 641 465 805 211 531 333 505 483 345 612 241 376 700 5 338 661 777 241 412 118 585 121 1 398 658 855 598 300 ...

output:

2
6
17
3
2
2
2
2
2
3
2
2
11
2
7
2
4
2
2
3
9
5
2
2
4
2
2
4
2
2
2
2
7
8
2
2
9
2
3
4
4
2
3
2
2
3
2
2
1
2
2
2
13
167
11
2
3
0
2
2
2
2
2
2
3
3
4
7
2
3
2
4
2
5
2
23
2
3
2
0
2
2
2
4
2
4
2
2
4
2
2
5
2
91
5
2
2
2
3
3
2
2
3
2
0
2
3
2
2
2
3
2
5
2
2
5
2
77
21
2
7
3
2
3
2
2
2
2
13
2
4
4
2
2
9
2
2
2
3
13
3
5
2
4
...

result:

ok 100000 numbers

Test #3:

score: 30
Accepted
time: 206ms
memory: 10208kb

input:

100000
6 8 75 85 89 8 88 56 1 64 37 6 28 16 87 74 57 51 5 72 39 85 100 54 1 97 77 40 97 95 65 56 37 13 44 23 68 49 85 79 27 57 75 81 1 26 61 45 97 31 85 61 51 37 30 53 1 51 11 57 49 22 40 67 49 85 53 89 1 97 88 57 79 6 61 61 36 75 71 53 81 91 91 1 91 1 29 67 47 81 81 37 71 14 17 26 65 59 36 7 97 77 ...

output:

5
2
4
2
4
4
4
0
6
2
2
7
8
2
3
2
4
8
2
2
2
8
2
2
2
0
4
1
3
2
2
4
10
2
3
0
2
13
2
2
3
2
2
2
5
2
3
2
0
3
6
2
0
2
3
2
3
34
2
2
7
2
2
8
2
2
10
2
0
0
2
2
2
3
2
2
2
3
2
5
2
2
2
2
2
2
5
10
34
2
2
3
3
2
3
2
2
2
2
20
4
13
4
4
2
50
5
3
2
2
10
2
3
2
3
4
2
12
3
7
12
5
2
5
3
4
2
2
3
2
2
2
2
2
2
2
4
2
2
2
2
2
0
13...

result:

ok 100000 numbers

Test #4:

score: 30
Accepted
time: 256ms
memory: 10324kb

input:

100000
6 7 6 6 1 1 9 1 7 6 3 4 6 6 5 1 8 6 6 3 2 7 1 3 6 3 9 2 1 7 6 10 7 5 7 7 3 1 1 6 1 3 3 2 5 1 9 2 1 10 3 7 1 1 7 3 4 6 5 5 10 8 7 3 9 5 4 9 5 1 2 1 10 1 7 1 9 2 9 5 1 1 9 9 1 10 7 1 6 5 3 9 3 6 10 7 6 9 7 3 9 1 1 7 6 9 5 3 4 1 9 7 9 3 8 10 1 6 7 9 4 1 5 1 1 5 1 1 6 5 7 3 9 7 7 5 6 3 4 7 6 5 5 ...

output:

2
4
2
2
2
0
0
2
0
5
2
0
2
2
2
0
3
2
0
2
2
0
2
1
3
2
4
0
0
1
2
4
2
2
0
2
0
0
2
0
2
0
4
2
2
2
2
0
2
2
3
2
2
5
4
3
0
2
2
2
3
3
2
1
2
0
1
2
2
2
4
2
2
2
0
2
4
0
2
2
3
4
2
0
3
2
2
4
2
2
0
0
4
4
1
2
2
2
3
2
2
2
0
2
2
5
0
2
4
1
2
2
2
2
2
2
0
2
2
2
2
0
4
2
2
5
0
2
4
2
2
5
2
0
2
4
2
0
4
2
2
2
2
2
0
2
5
2
4
2
...

result:

ok 100000 numbers

Subtask #3:

score: 40
Accepted

Test #5:

score: 40
Accepted
time: 734ms
memory: 10368kb

input:

99917
24947 3268 49683 43610 87927 86331 16017 19557 72137 16689 28231 87819 9481 2403 18661 8145 86091 90410 54635 10896 53999 43367 95987 23733 17359 94625 81763 44331 63663 6075 20784 94229 61578 3890 95047 32681 39491 33139 51629 34573 859 31797 22897 7647 52199 17817 6311 46787 20619 81037 5374...

output:

3
7
9
5
3123
34
5
3
2
7
8
45
34
350
11
515
3
0
40
1
11
2
5
2
3
267
6
2
3
11
333
13
0
5
11
424
676
17
7
103
5
11
4
10
3
4
1
23
2
7
4
63
7
1
0
93
10
7
9
5674
16
1
16
9
141
2
1
2
18
1
6
4
1
0
714
8
18
14
3
1
4
13
5
4
1
278
6
19
130
9
7
763
3
26
5
2
1427
4
3348
389
41
11
1564
362
10
5
8
1
2271
15
18
3
3...

result:

ok 99968 numbers

Test #6:

score: 40
Accepted
time: 682ms
memory: 10392kb

input:

99904
10367 10479 10591 10703 10815 10927 11039 11151 11263 11375 11487 11599 11711 11823 11935 12047 12159 12271 12383 12495 12607 12719 12831 12943 13055 13167 13279 13391 13503 13615 13727 13839 13951 14063 14175 14287 14399 14511 14623 14735 14847 14959 15071 15183 15295 15407 15519 15631 15743 ...

output:

12
9
342
3028
0
0
4
617
1
4
1
0
516
4
655
0
482
1
56
8
2
7
366
6
5551
3
1
102
25
648
25
19
0
1
2
2
813
261
1
33301
48
0
2
1
3
3
412
5
12
5
10
12
680
193
246
10
8
388
3
2
1
25
4
8
709
10
106
45
2
231
88
3
3
140
296
3
26
1
20
108
9
3
573
641
3
2
6
3
5551
29
9
4
10
1
6
26
2
117
2
1
6
143
1
2
276
7
31
0...

result:

ok 99924 numbers

Test #7:

score: 40
Accepted
time: 578ms
memory: 10256kb

input:

99969
25648 25858 26068 26278 26488 26698 26908 27118 27328 27538 27748 27958 28168 28378 28588 28798 29008 29218 29428 29638 29848 30058 30268 30478 30688 30898 31108 31318 31528 31738 31948 32158 32368 32578 32788 32998 33208 33418 33628 33838 34048 34258 34468 34678 34888 35098 35308 35518 35728 ...

output:

367
3
23
26
0
4
1
5
1
50
4
0
5
324
15
529
2
5
215
25
2
36
1
1
7
1
4
1
5
1
58
265
1
2
94
11
4
102
122
9
17
17
562
271
2
0
18
3
7
3
26
5
87
3
7
1
2
172
13
5
65
5
75
1
36
13
83
1
79
260
1
758
10
29
6
6
94
26
5
529
54
1667
5
8
5
2
318
1
6
85
282
2381
1
6
124
5
2
221
75
10
28
74
39
22
128
186
5
11108
45
...

result:

ok 99968 numbers

Test #8:

score: 40
Accepted
time: 401ms
memory: 10220kb

input:

99906
36465 45696 53812 65157 8362 50390 8938 66579 26693 23509 59735 63357 37477 90628 20147 72910 99559 37162 99384 68055 41090 33886 85000 37741 67533 62838 51629 98159 34652 32219 64124 29772 82734 49142 4703 53488 34548 33792 92462 74455 72552 15702 95270 78539 95968 59919 73874 85989 75481 135...

output:

0
10
4344
1
1
5
2351
11
1199
17
1
9
49
8
8
21
58
135
3
4
9
30
21
3
331
1
232
544
65
2
5
9
6
209
540
21
7
3
4
1
24
13
4
1
132
4
4
7
3
27
1
12
15
47
4
4344
2
17
8
3
1
111
0
22
4
6
3752
108
3
3
1052
4
4
101
7
360
3
1444
2
55
3
6
3
2
73
233
114
9
52
0
13
59
2
4
13
106
8
101
5
9
6
2
6
345
1
13
3
4
5
4
18...

result:

ok 99917 numbers

Test #9:

score: 40
Accepted
time: 418ms
memory: 10324kb

input:

99966
44799 72530 81392 43798 83470 66203 36496 90621 14743 58886 57175 17632 39281 51952 84112 28506 46662 77651 3258 5736 3873 75583 60096 4179 68022 6864 52499 86228 51707 9717 33268 6141 16004 41257 12889 34449 56219 68531 41082 10477 88198 76466 4391 66838 90572 15137 16809 59816 94083 13212 42...

output:

75
3
1
1
28
110
2
4
2
3
12
5
36
3
404
2
9
27
206
11
1
2
132
6
6
17
33
1
68
10
2
3
10
1
14
4
72
3610
148
1
9
2
7
4
78
9
16
208
3
1
6
3
3
2
62
1
8
5
8
2
154
2
2
101
2
115
1
9
83
518
1
138
11
6
6
7
1
5
109
54
14743
63
5
2
7
15
130
2
3
6
209
1
4
4
6
758
4
43
1
400
5
64
14
0
9
2
9
14
5
11
3
2
15
2
2
3
25...

result:

ok 99916 numbers

Test #10:

score: 40
Accepted
time: 409ms
memory: 10252kb

input:

99963
16111 1092 30535 68250 78002 71251 53420 37707 77827 76960 96449 627 10162 53821 54943 71088 60448 37958 6279 69907 4736 35587 45691 2165 58554 68958 51294 59907 9282 44970 56859 87998 11636 35967 26608 22820 33458 54516 40680 72697 35476 12105 75861 54756 43874 67663 68941 94121 85262 68565 7...

output:

1
4
7
3
6
196
22
0
3
483
5
2
3
32
6
0
12
5
22
113
7
1
807
507
5
1
13
14
2
3
5
4
0
75
475
9
3
0
18
5
14
4
668
13
3
12
1
3
4
4
1
145
3
1695
8
3
0
794
3
2
5
1
4
2
1
0
11
0
10
4
22
3
208
1
6
18
676
3
12
150
0
6
7
1
3
2564
0
13
40
5
33
4
18
59
1020
12
3
5
2
4
2
1
3124
20
5
4
6
2
15
44
0
6
338
1
540
7
74
...

result:

ok 99939 numbers

Test #11:

score: 40
Accepted
time: 767ms
memory: 10200kb

input:

99906
82922 16337 13778 79565 79931 7193 95297 41300 6080 72632 57248 29069 77522 36602 75833 24392 58469 44033 83057 70322 57176 90650 13406 78563 88808 23651 79955 14408 20912 63836 84119 24140 74351 59504 74342 52880 67070 15911 64409 47462 5804 61739 67175 23096 48878 77999 36425 12221 16721 477...

output:

1
16
6
4
13
5
9
3
6
4
6
1
5
23
145
7
0
16
9
205
8
13
6
0
7
3
6
4
7
6
22
6
2
3
6
22
7
9
11
3
6
5
6270
6
5
5
1
2
4
5
11
4
2
5
8
3
3
8
17
6
11
32
8
6
7
6
8
9
6
5
19
3
15
13
6
5
0
4
6
7
5
23
4
8
4
4
5
5
13
5
15
8
6
6
4
64
1
9
21
6
5
14
4
4
770
20
4
581
3
25
19
9
8
5
20
9
6
2
1
5
3
6
0
5
18
1
84
5
10
27
...

result:

ok 99979 numbers

Test #12:

score: 40
Accepted
time: 659ms
memory: 10204kb

input:

99947
64197 19476 49866 50373 45603 3729 33306 80571 31965 77622 2598 23841 42345 31779 12906 76089 73389 5916 5193 71136 82686 87639 14889 96102 49224 46869 52806 37185 36615 46713 19134 43422 77526 22122 43857 16407 42516 11346 68223 8118 42753 58509 23970 14970 1647 40206 81948 24909 29232 91605 ...

output:

1
35
17
183
102
3
18
3
26
91
13
16
31
6
0
16
4
27
2
5
31
7
14
8
40
3
3
13
2
3
18
4
22
6
22
5
26
2
7
2
25
4
31
55
29
9
2
23
21
12
1
22
51
2
28
59
8
3
8
7
14
7
1
10
117
32
20
21
11
1
19
27
4
2
21
528
4
16
31
0
12
8
7
3
438
22
2
13
17
13
4
10
1
6
48
5
9
65
15
1
14
8
4
29
90
361
1
13
12
9458
3
5
4
100
1...

result:

ok 99972 numbers

Test #13:

score: 40
Accepted
time: 768ms
memory: 10204kb

input:

99927
29417 29457 29497 29537 29577 29617 29657 29697 29737 29777 29817 29857 29897 29937 29977 30017 30057 30097 30137 30177 30217 30257 30297 30337 30377 30417 30457 30497 30537 30577 30617 30657 30697 30737 30777 30817 30857 30897 30937 30977 31017 31057 31097 31137 31177 31217 31257 31297 31337 ...

output:

1
1
4
10
225
583
79
99
24
337
21
1
426
38
4
25
11103
8
8
45
1
0
20
0
730
8
1299
0
2
4
10
4
8
1388
926
993
694
2
96
291
434
3
521
8328
816
12
10
2
22
1
4
0
1
585
1
428
424
4
775
10
0
581
1
19
4
125
3331
6
7
4
8
2
45
1
375
775
424
2
1
2
2
16655
165
2
477
249
6
1
1
877
4164
18
4
2
6
4
877
17
2
3
73
3
1...

result:

ok 99952 numbers

Test #14:

score: 40
Accepted
time: 798ms
memory: 10324kb

input:

99932
43593 32781 34995 46386 43014 61890 17664 82617 43026 86961 66666 27750 59190 15885 15360 87849 39027 94068 15960 47190 92316 64140 24957 25314 8355 43677 89757 10284 67470 80874 80307 41760 34869 48408 26550 41712 14283 57735 12918 65022 72120 17544 71319 48183 48438 35889 28683 40494 33342 8...

output:

3
1
6
2
14
2
4
14
1075
4759
0
1
5
19
0
0
16
21
5
678
873
831
292
7
7
7
17
2
717
0
13
3
487
28
2
1
28
39
1
3
1
7
698
12
16
4
8
5
20
2
0
26
4
1
115
11
29
352
2
13
4
2
120
5
558
559
25
1
10
25
11
39
2
5
9
123
5
27
6
1
14
7
559
597
4
6
1168
11
1586
3
10
448
14
7
1
559
4
3
767
559
2
694
1
22
28
3
1207
47...

result:

ok 99969 numbers

Test #15:

score: 40
Accepted
time: 669ms
memory: 10388kb

input:

99933
53702 53821 53940 54059 54178 54297 54416 54535 54654 54773 54892 55011 55130 55249 55368 55487 55606 55725 55844 55963 56082 56201 56320 56439 56558 56677 56796 56915 57034 57153 57272 57391 57510 57629 57748 57867 57986 58105 58224 58343 58462 58581 58700 58819 58938 59057 59176 59295 59414 ...

output:

21
5
3
1252
5
380
2
4
10
4
3845
1
4
1196
13
49966
3
965
1167
17
3
1251
116
10
830
25
5
8
6
2
829
1
3
10
8
2
3
1430
1
3
1472
1725
1002
2
1
1
2
0
4
3
2
7139
17
508
18
3
1
9
9
12
2382
1
2
2
4
4
59
5
3
1
0
552
0
1472
1
24983
1
8
3125
882
5553
12
4
1192
49966
31
18
1
14
12
6
20
360
0
1
2
4
1114
0
1
1221
...

result:

ok 99945 numbers

Test #16:

score: 40
Accepted
time: 812ms
memory: 10320kb

input:

99955
26855 15802 2134 7321 2593 2687 24214 1690 13324 7205 2738 28293 18996 13969 23792 125 27614 24171 31316 1431 6262 12580 15987 5113 18533 27132 6913 21196 25640 29503 18291 636 30349 22354 24189 10416 7289 20264 28039 611 15101 11624 27400 21614 4583 6885 7611 30788 8914 23634 32514 7770 12249...

output:

9
644
92
869
1
437
481
1449
109
3
5
293
11
62
2
8
354
1392
313
5
19
32
7
587
2
238
10
19
62
1
2
3
178
7
22
4
7
6
3
568
2382
0
1
3
26
3
7
6
5
0
41
239
18
3
8
16661
5
2
716
2
929
13
2
716
12
2
3
10
218
3
780
4
24
2778
17
631
3
505
6
10
239
16
2
2778
114
4
2223
3
36
675
697
3333
744
13
5
11
4
4
15
4763...

result:

ok 99964 numbers

Test #17:

score: 40
Accepted
time: 463ms
memory: 10220kb

input:

99998
65682 65811 65940 66069 66198 66327 66456 66585 66714 66843 66972 67101 67230 67359 67488 67617 67746 67875 68004 68133 68262 68391 68520 68649 68778 68907 69036 69165 69294 69423 69552 69681 69810 69939 70068 70197 70326 70455 70584 70713 70842 70971 71100 71229 71358 71487 71616 71745 71874 ...

output:

121
3
266
7
482
58
2
7
2
3
1
4
152
1
4
1
215
288
3
2
524
9
1
252
141
3
1
2
10
2
3
4
2
1
0
140
4
4
8
3
9
2
314
12
56
554
0
4
2
252
15
174
220
182
167
9
259
554
1
7
14
4
10
48
4
8
12
5
9
5
2
187
3
6
5
2
0
3
425
4
3
1
129
5
8
2
5
3
3
19
2
4
482
252
11
3
5
2
3
15
2
2
553
3
107
0
124
121
473
641
1
7
4
55...

result:

ok 99936 numbers

Test #18:

score: 40
Accepted
time: 518ms
memory: 10276kb

input:

99980
23171 57477 84150 24338 24376 56665 76788 38122 15873 38069 68995 62637 17428 24356 42605 82351 79440 88824 10013 12966 29637 16019 52062 45761 12660 21134 18507 12236 1375 15267 30874 25342 27416 53840 58861 26304 57875 58000 85953 19945 8463 21052 2492 33035 16836 72753 39564 81784 5732 1661...

output:

250
1
5
13
6
1
3
5
1
938
0
1
11
411
81
36
663
3
3
2
5
2
3
13
0
11
1
5
321
1
10
1731
13
222
7
1
1
2
416
3
782
123
1
1580
2
1
4
1177
2
3
2
6
3
143
5
7
17
2
3
1
2
57
3
659
5
0
527
9
13
2915
1
8
4
1
507
5
49
2727
2
3
5
2
4
56
46
12
5
1
1
1
20
9
7
0
1184
2
21
53
2
11
3
1
0
16
1
2
1
404
7
3
2647
18
8
12
7...

result:

ok 99913 numbers

Test #19:

score: 40
Accepted
time: 622ms
memory: 10224kb

input:

99946
22420 554 11681 15275 32100 27903 20503 20756 11952 29974 3952 21743 6733 17201 33231 7827 14641 20635 16701 10203 14225 1395 24879 18988 25606 22693 25884 19261 2555 16698 17455 29625 2418 5696 29195 17345 22493 28916 18263 17086 26221 1293 12348 29740 30803 15426 29511 13568 19504 29975 6922...

output:

571
852
3
767
18
175
14
198
559
2
727
593
282
128
951
533
236
823
37
3
1
5
1285
559
624
561
20
3
19
307
1
8
454
360
560
1
3
327
1
3
2
561
858
418
430
8
4
284
316
762
530
560
1012
762
3
951
1119
476
2
583
2
396
489
1
11
316
241
2
8
702
376
3
42
518
1
396
1
212
4
130
596
2
388
3
460
658
320
8
2
477
95...

result:

ok 99923 numbers

Test #20:

score: 40
Accepted
time: 585ms
memory: 10320kb

input:

99982
90772 54888 87726 17489 60154 76879 64610 5653 40740 45970 21750 48680 63759 8980 94448 18843 515 70117 55233 24998 82403 44684 32193 38282 39295 13933 89108 7269 62294 51445 47786 74428 39794 9246 28839 91162 60679 86418 43728 49436 61292 55788 56998 18268 23661 26744 7281 8903 73462 66512 41...

output:

8
99
5
4
14
11
1
26
2
67
11
5
5
5
1
240
58
3
10
3
68
70
12
5
116
4
127
17
3
74
53
26
89
46
18
8
6
7
4
282
22
120
4
175
9
2
1
12
7
6
102
117
95
9
250
29
3
9
113
16
49
62
23
3
2
1
3
1
35
36
53
45
2
1
3
60
1
3
5
5
5
10
512
0
12
45
9
6
26
61
2
2
55
6
5
4
67
4
10
17
146
3
49
26
4
40
3
2
6
0
7
7
57
35
104...

result:

ok 99903 numbers

Test #21:

score: 40
Accepted
time: 446ms
memory: 10276kb

input:

99916
88963 88964 88965 88966 88967 88968 88969 88970 88971 88972 88973 88974 88975 88976 88977 88978 88979 88980 88981 88982 88983 88984 88985 88986 88987 88988 88989 88990 88991 88992 88993 88994 88995 88996 88997 88998 88999 89000 89001 89002 89003 89004 89005 89006 89007 89008 89009 89010 89011 ...

output:

0
43920
43681
0
22145
88866
0
88885
11086
38496
22240
88918
12654
29174
29125
88942
88658
88885
17693
88935
44077
9645
12
29647
42
75
88638
8892
88943
88908
86525
0
13
44154
88759
22239
10885
44338
25689
0
44469
14691
44063
88949
38496
88959
88761
18
29345
22201
77016
29223
88871
38578
44382
19
0
29...

result:

ok 99925 numbers

Test #22:

score: 40
Accepted
time: 332ms
memory: 10376kb

input:

99958
72360 72361 72362 72363 72364 72365 72366 72367 72368 72369 72370 72371 72372 72373 72374 72375 72376 72377 72378 72379 72380 72381 72382 72383 72384 72385 72386 72387 72388 72389 72390 72391 72392 72393 72394 72395 72396 72397 72398 72399 72400 72401 72402 72403 72404 72405 72406 72407 72408 ...

output:

36171
14467
66310
0
18090
71862
71610
36176
23373
71502
15
36149
72325
36034
109
72342
24090
36171
72356
1
18019
17754
0
16
0
22
72246
10
4
14432
71780
82
72075
71652
0
72360
39
36070
36162
70568
31335
31418
69541
24112
72052
582
72330
23439
22058
35756
4
72269
72288
72354
36173
36074
23940
72355
24...

result:

ok 99908 numbers

Test #23:

score: 40
Accepted
time: 229ms
memory: 10312kb

input:

99991
76413 76414 76415 76416 76417 76418 76419 76420 76421 76422 76423 76424 76425 76426 76427 76428 76429 76430 76431 76432 76433 76434 76435 76436 76437 76438 76439 76440 76441 76442 76443 76444 76445 76446 76447 76448 76449 76450 76451 76452 76453 76454 76455 76456 76457 76458 76459 76460 76461 ...

output:

36716
2
38201
76384
73613
38192
73947
38093
38079
1343
65
76335
37233
76354
75515
76188
27
76384
68884
38016
76353
76409
425
38142
37694
0
74120
67885
75712
36108
104
45648
75557
76247
8
37028
76327
37175
38198
37991
76399
4
76401
75962
76
76392
76400
76391
0
76266
35144
38172
75450
76326
141
76410
...

result:

ok 99901 numbers

Test #24:

score: 40
Accepted
time: 640ms
memory: 10204kb

input:

99971
91944 91697 90145 90865 90193 94122 93646 94368 94320 93016 90318 94953 93042 89993 90163 91800 93315 91485 94172 92288 91994 91678 93833 90841 90591 91444 93336 92524 91972 91898 94237 94568 91817 94855 90707 94432 93240 90063 90307 94701 91852 92822 92705 90620 93439 90415 92452 94908 92551 ...

output:

3518
45522
6784
12
3947
2
45522
31657
47486
47485
5587
3120
94122
3653
97
15829
4076
5936
4780
0
0
91045
4745
3120
18995
29994
44992
2469
15829
23743
0
3958
15829
30012
45522
0
30049
4522
5277
30049
9029
3850
44987
18995
30335
18995
2
16
89984
31657
8
4999
18994
121
9498
46789
13568
0
94122
18995
23...

result:

ok 99923 numbers

Test #25:

score: 40
Accepted
time: 328ms
memory: 10268kb

input:

99923
91971 90661 94136 91147 94368 91981 91600 91088 90588 94556 91997 92347 94520 90598 94003 93046 94655 90673 91406 94067 93311 92084 90212 90207 90042 92609 91863 94662 91446 92244 93171 90934 91271 93790 90525 91333 92035 91734 93673 89999 91014 91484 94762 91498 91744 92737 92317 90238 91310 ...

output:

47462
25
45
1791
94923
90510
90052
47462
30080
45020
31641
31641
1113
6686
44965
12093
45020
94923
90052
29977
94923
22495
17
47462
94923
16534
94923
94923
89969
0
47461
31641
9
8
16534
973
23731
13
40
94923
10
45034
90522
1
90052
47462
16534
94923
90197
94923
94923
149
3
45020
31641
23731
11
89930
...

result:

ok 99928 numbers

Test #26:

score: 40
Accepted
time: 224ms
memory: 10284kb

input:

99960
90418 94835 93264 92769 93308 91787 93859 91748 91021 90648 93001 93570 94474 94542 94648 92930 93458 93669 93884 91267 92718 91769 92465 94406 90096 92434 90233 91047 93988 94551 94242 91181 90581 92304 91233 92439 92591 91933 91803 91003 91585 90134 90719 94580 92339 90677 91947 93589 92461 ...

output:

1120
89961
89963
89963
90128
89963
90096
89989
5
89963
89963
1826
89989
3
94960
89963
90096
89963
89989
90096
89963
89963
89961
89961
89963
89963
90128
2045
89989
89961
969
17
89963
94542
89989
94960
90096
1036
94960
116
89967
1145
89967
89963
90096
94960
13566
90088
91933
1508
90096
90096
89963
899...

result:

ok 99957 numbers

Test #27:

score: 40
Accepted
time: 380ms
memory: 10204kb

input:

99997
93355 91593 90014 90911 90001 94898 92767 91124 91775 90983 92168 92256 94891 94592 91155 90655 93274 94130 91569 92292 92303 91456 93561 90582 90584 90636 93268 90361 94627 90109 90902 92705 93835 91933 94643 92214 91526 90779 92019 93701 94501 91499 91756 93251 93577 90840 90029 90172 90161 ...

output:

18999
18999
22521
18048
45005
22588
22521
18432
22542
45144
94997
1203
27
4
90001
20
45005
0
833
45028
5
90005
18000
0
45005
7
30003
31666
45005
23137
0
5
0
90003
22533
4131
0
22540
45121
18105
1392
47499
47499
22952
45000
31069
30018
3
45005
31666
47014
22572
31666
90001
30004
1827
2879
90003
2
225...

result:

ok 99959 numbers

Test #28:

score: 40
Accepted
time: 591ms
memory: 10284kb

input:

99953
91161 93272 94057 94188 90905 93235 93813 90923 89969 94041 90509 91707 94796 93363 94622 92384 91582 92011 94294 92295 91826 94943 90137 90434 93909 90983 91776 94561 91862 94509 93331 92065 90127 92496 93409 90151 94315 92035 90649 93055 90864 90155 90038 93783 92359 91644 94031 93066 91832 ...

output:

89958
2
2261
3481
5
2713
0
2967
8633
11248
55
10007
6433
6570
2355
3340
89960
3799
0
66
2045
23044
3460
5935
2638
2208
5276
2
26
2209
3097
2813
2316
3275
2374
6053
5319
9009
3053
10437
4341
4522
8633
2499
4318
3466
3763
1357
5326
1871
12882
1092
8190
3392
3517
15060
1113
18034
4504
3234
8190
30016
7...

result:

ok 99928 numbers

Test #29:

score: 40
Accepted
time: 429ms
memory: 10324kb

input:

99901
83586 80579 82121 86540 84956 87139 81759 88184 84008 89403 83958 85733 85201 87389 79926 80001 83269 89249 87765 89609 86843 81525 87338 89452 82675 83536 87427 82405 85008 82845 86880 82296 88680 88645 89233 80622 81189 81305 80111 82056 89603 80201 87968 80841 89829 82203 88396 81008 85741 ...

output:

3533
8
1168
1662
3994
999
79
2008
1543
1249
5
1274
1126
893
860
9
1
1913
4
967
4786
10
1916
1323
1799
988
1222
101
1083
2725
918
1021
1791
1303
43
7277
2551
2
2
5994
4
8004
30
2900
9
872
2305
2725
2084
97
39952
903
8046
927
0
2
20154
7
3
2595
1791
2021
36
2198
1376
2517
956
3
1110
79903
1013
1955
12...

result:

ok 99984 numbers

Test #30:

score: 40
Accepted
time: 389ms
memory: 10208kb

input:

99996
81840 84895 87406 87828 82094 88310 80167 81806 82076 81635 87402 88136 82772 85174 83360 83368 80990 88203 86163 83258 84658 82953 86387 87097 86098 83255 88931 82879 88471 83660 80241 86446 88084 81612 88592 85260 83276 83915 81917 80967 82110 87082 80028 88413 82083 86877 81241 84877 84243 ...

output:

25
9
37
8
71
3217
0
23
4
2003
18
8
31
1607
7
5
84
1667
1
0
3
1294
1915
1
107
3
131
145
19
115
12
4
1
14
3
1098
5
8
0
7
6
8
1
5
7
1486
7
6
13
4
1364
6
3
4
1085
6
15
5
21
4
6
1
23
9
4
97
2813
6
7
4
3343
9
4
3
10
11
52
10
2723
3
16
1
8
4710
14
8
1011
2
919
2
7
2
4
14
1185
9
6
52
6
3215
5
3
16
1019
72
1...

result:

ok 99930 numbers

Test #31:

score: 40
Accepted
time: 356ms
memory: 10272kb

input:

99981
3475 3743 4011 4279 4547 4815 5083 5351 5619 5887 6155 6423 6691 6959 7227 7495 7763 8031 8299 8567 8835 9103 9371 9639 9907 10175 10443 10711 10979 11247 11515 11783 12051 12319 12587 12855 13123 13391 13659 13927 14195 14463 14731 14999 15267 15535 15803 16071 16339 16607 16875 17143 17411 2...

output:

125
254
241
44
352
443
8
348
375
10
0
855
35
1
4
746
17
67
4
388
5
8
5
5
641
0
522
65
0
422
354
506
8
138
23
1282
4
2
2
211
5
6
5
397
6
746
189
6
5
23
306
8
277
1
95
5
225
242
23
926
901
341
211
8
8
95
488
2
500
3
235
395
6
396
656
2
22
396
0
2
2
1
3
181
25
396
855
9
9
172
0
470
2
29
262
7
0
70
1
20...

result:

ok 99993 numbers

Test #32:

score: 40
Accepted
time: 345ms
memory: 10220kb

input:

99937
41574 41577 41580 41583 41586 41589 41592 41595 41598 41601 41604 41607 41610 41613 41616 41619 41622 41625 41628 41631 41634 41637 41640 41643 41646 41649 41652 41655 41658 41661 41664 41667 41670 41673 41676 41679 41682 41685 41688 41691 41694 41697 41700 41703 41706 41709 41712 41715 41718 ...

output:

211
8
7
9
115
257
209
187
23
6
143
149
127
16
40
207
332
233
26
1094
80
4
10
37
118
74
3
59
2
520
261
11
10
169
4
3
20
279
3
234
13
11
3
0
10
138
1149
224
1
5
186
172
8
207
328
26
6
6
669
402
61
1
115
220
3
25
18
12
411
952
3
195
55
315
330
195
13849
176
26
9
1708
11
7
29
320
9
3
99
21
167
188
4
238...

result:

ok 99913 numbers

Test #33:

score: 40
Accepted
time: 400ms
memory: 10208kb

input:

99967
75493 75532 75571 75610 75649 75688 75727 75766 75805 75844 75883 75922 75961 76000 76039 76078 76117 76156 76195 76234 76273 76312 76351 76390 76429 76468 76507 76546 76585 76624 76663 76702 76741 76780 76819 76858 76897 76936 76975 77014 77053 77092 77131 77170 77209 77248 77287 77326 77365 ...

output:

460
531
129
776
6
4166
877
13
1
547
0
1333
178
1333
3
563
9
188
48
5
926
3484
0
870
78
725
118
1549
22
725
574
2
10
1
877
1907
581
10
786
761
1852
3
243
1
1
14
520
423
2
761
241
8
2113
630
1
1389
11
2222
241
322
5
1
761
3333
4
1653
706
404
4
864
394
3
0
169
0
2
741
877
2
844
1150
243
98
2
4
1264
222...

result:

ok 99917 numbers

Test #34:

score: 40
Accepted
time: 512ms
memory: 10312kb

input:

99959
66570 66852 67134 67416 67698 67980 68262 68544 68826 69108 69390 69672 69954 70236 70518 70800 71082 71364 71646 71928 72210 72492 72774 73056 73338 73620 73902 74184 74466 74748 75030 75312 75594 75876 76158 76440 76722 77004 77286 77568 77850 78132 78414 78696 78978 79260 79542 79824 80106 ...

output:

2499
2
0
2
0
0
36
0
9
5
45
12495
11
410
5
1111
2
336
2
5
833
495
1000
179
2
2
100
3
25
781
4
603
0
2
3
373
1
0
648
10
714
217
12
2
582
345
1
0
468
8
188
0
20
603
2
458
2000
5
0
0
2
17
1069
1
13
3
2
179
0
12
186
323
10
9996
21
1
504
966
372
4
45946
0
9
51
51
714
568
769
256
443
2
2
111
179
0
227
2940...

result:

ok 99976 numbers

Test #35:

score: 40
Accepted
time: 46ms
memory: 10252kb

input:

100000
0 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...

output:

100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100...

result:

ok 100000 numbers

Test #36:

score: 40
Accepted
time: 267ms
memory: 10284kb

input:

100000
0 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...

output:

100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100000
0
100...

result:

ok 100000 numbers

Test #37:

score: 40
Accepted
time: 144ms
memory: 10392kb

input:

100000
0 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...

output:

1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0
1588
0...

result:

ok 100000 numbers