QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#219512#7146. Geometric progressionckiseki#AC ✓74ms12672kbC++201.6kb2023-10-19 15:49:462023-10-19 15:49:46

Judging History

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

  • [2023-10-19 15:49:46]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:12672kb
  • [2023-10-19 15:49:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  for (int f = 0; L != R; ++f)
    cerr << (f ? ", " : "") << *L++;
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define orange(...) safe
#define debug(...) safe
#endif

template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

const int maxn = 1000025;

bool mark[maxn];
int id[maxn];
int a[maxn];

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    id[a[i]] = i + 1;
  }

  int ans = 0;
  for (int i = 1; i < maxn; i++) mark[i] = true;

  for (int i = 1; i < maxn; i++) {
    if (mark[i]) {
      vector<pair<int,int>> nums;
      for (int j = 1; j * j * i < maxn; j++) {
        mark[j * j * i] = false;
        if (id[j * j * i])
          nums.emplace_back(id[j * j * i], j);
      }
      sort(all(nums));

      for (auto [ix, x] : nums) {
        for (auto [iy, y] : nums) {
          if (iy >= ix) break;
          int64_t z = 1LL * x * y * i;
          debug(z, ix, iy, id[z]);
          if (z < maxn && iy < id[z] && id[z] < ix) {
            ++ans;
          }
        }
      }
    }
  }
  cout << ans << '\n';

  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 8700kb

input:

3
1 2 4

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 6ms
memory: 8504kb

input:

4
1 2 4 8

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 2ms
memory: 8396kb

input:

10
4 5 6 7 8 9 10 12 14 15

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 5ms
memory: 6540kb

input:

10
1 3 6 7 8 9 10 12 13 14

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 5ms
memory: 7952kb

input:

10
3 4 5 6 9 11 12 13 14 15

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 5ms
memory: 8208kb

input:

10
1 4 5 6 8 9 10 12 13 14

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 5ms
memory: 8468kb

input:

10
1 2 4 5 7 9 10 11 13 14

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 2ms
memory: 7972kb

input:

10
2 3 4 6 8 9 10 11 14 15

output:

2

result:

ok 1 number(s): "2"

Test #9:

score: 0
Accepted
time: 5ms
memory: 6628kb

input:

10
2 3 4 5 6 8 9 10 13 15

output:

2

result:

ok 1 number(s): "2"

Test #10:

score: 0
Accepted
time: 2ms
memory: 6624kb

input:

10
1 2 3 4 6 8 9 10 14 15

output:

4

result:

ok 1 number(s): "4"

Test #11:

score: 0
Accepted
time: 3ms
memory: 8660kb

input:

10
1 2 4 5 6 7 9 10 13 14

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 5ms
memory: 7720kb

input:

10
1 2 3 6 7 8 9 10 12 15

output:

2

result:

ok 1 number(s): "2"

Test #13:

score: 0
Accepted
time: 5ms
memory: 8324kb

input:

1000
1 2 5 6 7 8 9 13 14 15 16 17 18 19 21 24 26 28 31 32 33 34 35 37 40 41 42 43 44 45 46 47 48 50 51 53 54 55 56 58 60 61 63 64 65 68 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 96 97 99 100 103 104 107 109 110 111 112 114 116 117 118 119 120 121 122 123 124 125 126 127...

output:

835

result:

ok 1 number(s): "835"

Test #14:

score: 0
Accepted
time: 5ms
memory: 6636kb

input:

1000
1 2 3 4 5 6 7 9 11 14 15 16 19 21 22 23 27 29 30 31 32 33 34 36 38 39 42 43 46 50 51 52 53 54 56 58 59 61 62 63 64 65 66 67 68 69 71 72 73 74 77 78 79 80 82 83 85 86 87 91 92 93 94 98 99 102 104 107 108 109 110 111 112 113 114 115 116 117 120 122 123 124 126 127 128 129 131 132 134 137 139 141 ...

output:

740

result:

ok 1 number(s): "740"

Test #15:

score: 0
Accepted
time: 5ms
memory: 8536kb

input:

1000
1 2 3 4 6 7 9 10 11 15 16 17 18 19 22 24 25 26 27 29 30 32 33 35 36 37 38 39 42 43 44 45 46 48 50 51 52 53 54 55 59 60 61 63 64 65 67 69 70 71 72 74 77 81 83 84 85 86 87 90 93 95 96 97 101 104 107 108 110 111 112 113 115 116 118 119 124 127 129 130 131 134 135 136 137 140 141 142 143 144 145 14...

output:

792

result:

ok 1 number(s): "792"

Test #16:

score: 0
Accepted
time: 6ms
memory: 6896kb

input:

1000
1 3 6 8 10 12 13 15 16 17 19 20 22 24 25 29 30 31 33 34 36 37 39 41 42 43 49 50 51 52 54 56 57 59 60 61 62 63 64 65 66 68 69 70 73 74 75 77 81 82 84 85 86 87 88 89 93 94 95 96 98 99 102 105 106 107 110 113 115 117 119 120 121 122 124 125 127 128 130 131 132 136 137 138 139 141 142 143 144 145 1...

output:

737

result:

ok 1 number(s): "737"

Test #17:

score: 0
Accepted
time: 2ms
memory: 7944kb

input:

1000
2 5 6 8 9 11 12 13 15 16 17 19 21 24 25 27 28 29 31 33 34 35 36 37 40 44 45 46 47 48 49 50 51 52 53 54 55 56 59 61 62 63 64 65 66 67 68 69 72 73 74 75 76 79 80 81 83 84 86 87 91 93 94 95 96 97 99 100 102 103 104 105 106 107 109 111 113 114 116 117 118 119 120 123 124 125 126 127 128 130 131 132...

output:

752

result:

ok 1 number(s): "752"

Test #18:

score: 0
Accepted
time: 6ms
memory: 8564kb

input:

1000
1 3 6 7 10 11 13 14 15 17 18 19 21 22 23 24 25 26 27 28 31 34 35 36 37 38 40 41 42 43 44 46 48 49 50 51 53 54 56 58 59 60 61 62 65 66 67 69 70 72 73 75 76 79 80 81 83 84 85 89 90 92 93 95 98 101 102 103 104 106 107 108 109 111 112 114 117 118 120 121 122 124 125 130 131 133 134 135 136 137 139 ...

output:

714

result:

ok 1 number(s): "714"

Test #19:

score: 0
Accepted
time: 5ms
memory: 6664kb

input:

1000
1 2 3 4 5 6 8 9 10 11 12 13 14 18 21 22 23 24 26 28 30 31 32 33 36 38 39 40 41 42 44 46 47 48 49 51 55 59 60 64 65 66 67 68 69 70 71 73 75 76 78 79 81 82 83 84 85 88 93 95 98 99 102 103 104 105 106 108 109 110 112 113 116 118 119 120 123 124 125 126 127 131 134 135 138 139 140 141 144 145 146 1...

output:

707

result:

ok 1 number(s): "707"

Test #20:

score: 0
Accepted
time: 5ms
memory: 8332kb

input:

1000
4 5 7 8 9 10 11 14 16 17 18 19 20 23 24 25 27 28 30 33 35 36 37 38 41 43 45 47 48 49 50 51 52 55 61 62 63 64 65 66 69 70 71 72 73 74 75 78 80 81 82 83 88 89 90 91 92 94 95 97 99 102 106 107 109 112 113 115 117 119 120 121 124 125 126 128 129 130 132 133 135 136 137 138 140 143 148 149 150 152 1...

output:

858

result:

ok 1 number(s): "858"

Test #21:

score: 0
Accepted
time: 2ms
memory: 6548kb

input:

1000
1 2 3 4 6 7 8 9 13 14 17 18 19 24 26 27 29 30 31 32 35 36 37 38 39 42 43 44 45 47 48 50 51 53 54 55 59 60 61 62 63 64 66 67 68 69 70 71 72 74 75 79 80 81 84 85 86 87 88 89 90 92 93 94 95 97 100 101 104 105 106 107 108 109 110 113 115 116 117 118 120 121 122 123 124 125 126 129 130 131 132 133 1...

output:

970

result:

ok 1 number(s): "970"

Test #22:

score: 0
Accepted
time: 5ms
memory: 7732kb

input:

1000
1 3 4 5 6 7 8 11 12 13 14 15 16 17 18 20 21 22 23 24 27 28 29 30 35 37 38 39 40 41 44 46 49 50 51 52 54 55 58 59 60 61 62 63 64 65 66 67 68 70 71 73 74 75 76 77 79 80 81 86 87 89 90 91 92 94 96 97 100 101 105 106 107 110 114 115 116 117 118 120 121 122 123 124 125 126 127 128 129 131 134 136 13...

output:

742

result:

ok 1 number(s): "742"

Test #23:

score: 0
Accepted
time: 50ms
memory: 12420kb

input:

500000
1 7 10 12 13 18 19 23 24 26 31 32 33 34 36 37 38 40 43 44 50 57 58 59 60 61 62 63 64 65 66 68 71 74 77 78 79 82 83 84 87 88 90 93 96 97 104 105 106 107 108 109 112 113 117 120 121 126 128 130 132 135 138 139 141 143 144 145 146 148 150 151 155 156 158 160 163 164 170 171 172 173 175 176 177 1...

output:

474875

result:

ok 1 number(s): "474875"

Test #24:

score: 0
Accepted
time: 51ms
memory: 12312kb

input:

500000
2 3 7 9 10 14 16 17 19 32 33 35 39 41 45 46 48 49 50 52 53 56 61 62 63 64 68 69 75 77 79 83 84 85 86 87 88 89 90 97 98 100 102 103 105 107 109 114 116 120 124 125 128 129 130 131 132 135 136 137 141 142 144 145 147 151 152 153 155 156 157 158 162 165 171 172 173 177 178 180 186 188 189 192 19...

output:

458383

result:

ok 1 number(s): "458383"

Test #25:

score: 0
Accepted
time: 52ms
memory: 12400kb

input:

500000
1 3 5 7 8 10 11 16 17 19 24 26 27 34 39 40 41 42 44 45 46 48 51 56 57 58 59 62 65 68 69 71 75 76 77 78 79 80 83 84 88 90 91 94 95 97 98 104 106 107 108 110 118 120 121 127 129 130 131 133 135 137 138 139 142 145 147 151 155 156 158 159 160 161 163 165 166 171 172 173 175 176 177 182 183 185 1...

output:

464913

result:

ok 1 number(s): "464913"

Test #26:

score: 0
Accepted
time: 47ms
memory: 12404kb

input:

500000
2 4 5 6 7 11 12 13 14 15 16 19 23 29 31 32 35 36 37 38 40 42 44 45 46 47 49 50 53 56 59 64 68 69 71 72 73 76 81 82 83 84 86 87 88 89 90 91 92 93 96 98 99 100 106 107 108 109 111 112 113 114 115 116 119 120 121 126 129 131 132 133 135 138 141 143 145 146 148 149 152 155 159 161 162 163 165 166...

output:

469229

result:

ok 1 number(s): "469229"

Test #27:

score: 0
Accepted
time: 51ms
memory: 12472kb

input:

500000
1 2 3 4 5 6 7 8 9 10 13 15 19 21 23 24 25 30 32 34 36 38 39 41 42 45 46 47 49 50 52 53 54 55 57 60 61 62 64 66 67 69 75 76 78 79 81 82 86 88 89 90 92 93 95 96 99 101 102 105 106 113 114 117 119 120 122 123 127 130 131 132 133 138 139 140 142 144 146 148 149 151 152 153 154 155 156 157 158 159...

output:

472480

result:

ok 1 number(s): "472480"

Test #28:

score: 0
Accepted
time: 51ms
memory: 12420kb

input:

500000
1 2 3 9 11 13 14 15 16 18 20 24 30 31 34 36 38 39 40 46 48 50 51 53 55 60 65 66 67 69 70 72 74 75 76 78 79 81 83 84 86 87 88 91 93 94 95 96 97 103 104 106 108 110 111 112 114 119 120 121 128 130 133 138 143 148 150 151 152 155 160 162 165 168 170 174 175 176 177 179 181 182 188 189 190 191 19...

output:

469369

result:

ok 1 number(s): "469369"

Test #29:

score: 0
Accepted
time: 51ms
memory: 12312kb

input:

500000
2 3 4 5 6 7 9 13 15 18 21 24 25 29 30 32 33 34 35 36 37 38 40 41 43 46 49 50 52 55 56 57 59 61 64 65 66 67 68 70 72 73 75 77 78 79 83 85 87 88 91 93 95 96 101 105 107 108 110 113 114 118 119 120 121 122 128 131 134 136 137 138 139 141 143 145 146 148 149 150 158 172 174 175 176 178 179 180 18...

output:

469626

result:

ok 1 number(s): "469626"

Test #30:

score: 0
Accepted
time: 46ms
memory: 12400kb

input:

500000
5 8 9 10 12 13 14 17 18 20 22 23 25 26 27 30 31 32 33 35 41 42 48 52 54 57 59 60 64 65 66 70 71 72 74 77 80 81 84 85 86 88 89 90 92 93 97 101 102 106 107 112 114 116 119 120 121 122 123 125 129 131 133 136 138 140 150 152 153 155 156 157 158 160 164 166 167 168 170 171 173 176 177 179 184 185...

output:

473306

result:

ok 1 number(s): "473306"

Test #31:

score: 0
Accepted
time: 51ms
memory: 12628kb

input:

500000
1 3 4 6 7 12 14 15 18 19 21 22 23 25 27 30 31 34 40 41 43 46 47 48 50 51 52 55 56 57 58 59 62 63 65 67 69 70 71 72 73 75 76 77 78 80 83 85 86 87 88 89 90 92 93 95 97 103 106 107 108 111 112 113 114 115 116 117 118 120 122 123 124 126 128 129 130 132 133 134 135 136 138 139 141 142 143 144 146...

output:

465139

result:

ok 1 number(s): "465139"

Test #32:

score: 0
Accepted
time: 48ms
memory: 12376kb

input:

500000
1 8 10 11 13 15 17 20 21 22 23 26 29 32 34 36 38 41 42 43 48 49 50 52 53 55 56 57 58 59 62 63 64 66 67 73 74 76 77 79 80 83 84 85 86 87 88 89 91 92 95 97 100 101 103 104 105 108 110 111 117 118 120 122 125 127 131 134 135 138 141 143 144 149 151 152 153 154 159 163 164 165 167 170 171 172 176...

output:

458185

result:

ok 1 number(s): "458185"

Test #33:

score: 0
Accepted
time: 67ms
memory: 12372kb

input:

950000
1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 19 20 22 23 24 25 26 27 28 29 30 32 33 34 35 36 37 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 65 66 67 68 69 70 71 72 73 74 75 78 79 80 81 82 84 85 86 87 88 89 90 92 93 94 95 96 98 99 100 101 102 103 104 105 106 107 108 10...

output:

3229761

result:

ok 1 number(s): "3229761"

Test #34:

score: 0
Accepted
time: 71ms
memory: 12380kb

input:

950000
1 2 3 4 5 6 7 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 71 72 73 74 75 76 78 79 80 81 82 83 84 85 86 87 88 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104...

output:

3234090

result:

ok 1 number(s): "3234090"

Test #35:

score: 0
Accepted
time: 68ms
memory: 12432kb

input:

950000
1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 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 67 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 97 98 99 100 101 102 103 104 10...

output:

3218897

result:

ok 1 number(s): "3218897"

Test #36:

score: 0
Accepted
time: 71ms
memory: 12436kb

input:

950000
1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 1...

output:

3228622

result:

ok 1 number(s): "3228622"

Test #37:

score: 0
Accepted
time: 71ms
memory: 12488kb

input:

950000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 42 43 44 45 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 82 83 84 85 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 10...

output:

3224461

result:

ok 1 number(s): "3224461"

Test #38:

score: 0
Accepted
time: 69ms
memory: 12672kb

input:

950000
1 2 3 4 5 6 7 8 9 10 11 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 67 68 69 70 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 98 99 100 101 102 103 1...

output:

3231280

result:

ok 1 number(s): "3231280"

Test #39:

score: 0
Accepted
time: 74ms
memory: 12472kb

input:

950000
1 2 3 5 6 7 8 9 10 11 12 13 14 15 16 18 19 21 22 23 25 26 27 28 29 30 31 32 33 35 36 37 39 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107...

output:

3227884

result:

ok 1 number(s): "3227884"

Test #40:

score: 0
Accepted
time: 73ms
memory: 12664kb

input:

950000
1 2 3 4 5 6 7 8 9 10 11 12 13 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 43 44 45 46 47 48 49 50 51 52 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 98 99 101 102 103 104 105 ...

output:

3219928

result:

ok 1 number(s): "3219928"

Test #41:

score: 0
Accepted
time: 68ms
memory: 12400kb

input:

950000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40 41 42 43 44 47 48 49 50 51 52 53 54 55 56 57 58 59 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 87 88 89 90 91 92 93 94 96 98 100 101 102 104 105 106 107 108 ...

output:

3233936

result:

ok 1 number(s): "3233936"

Test #42:

score: 0
Accepted
time: 67ms
memory: 12592kb

input:

950000
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 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 67 68 69 70 71 72 73 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 92 93 94 95 96 97 98 99 100 101 102 103 104 ...

output:

3236120

result:

ok 1 number(s): "3236120"

Test #43:

score: 0
Accepted
time: 74ms
memory: 12380kb

input:

1000000
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:

3770060

result:

ok 1 number(s): "3770060"

Extra Test:

score: 0
Extra Test Passed