Submission #847343


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxw = 1e12;

int root(int x) {
    int ans = sqrt(x);
    while (ans * ans < x) ans++;
    while (ans * ans > x) ans--;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n;
    cin >> n;
    map<int, int> d;
    map<int, int> cnt;
    for (int t = 0; t < n; t++) {
        int x; cin >> x;
        int inv = 1;
        int y = 1;
        for (int i = 2; i * i * i <= x; i++) {
            int k = 0;
            while (x % i == 0) {
                x /= i;
                k++;
            }
            k %= 3;
            for (int j = 0; j < k; j++) y *= i;
            for (int j = 0; j < (3 - k) % 3; j++) inv = min(maxw, inv * i);
        }
        y *= x;
        int r = root(x);
        if (r * r == x) {
            inv *= r;
        } else {
            if (inv > maxw / x / x) inv = maxw;
            else inv *= x * x;
        }
        d[y] = inv;
        cnt[y]++;
    }

    int ans = 0;
    for (auto p: d) {
        if (p.second == p.first) {
            ans += 2;
        } else if(d.find(p.second) == d.end()) {
            ans += 2 * cnt[p.first];
        } else {
            ans += max(cnt[p.first], cnt[p.second]);;
        }
    }

    cout << ans / 2 << '\n';
}

Submission Info

Submission Time
Task D - Anticube
User komendart
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 1374 Byte
Status AC
Exec Time 2804 ms
Memory 12800 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1100 / 1100
Status
AC × 3
AC × 51
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 1075 ms 12800 KB
02.txt AC 1092 ms 12800 KB
03.txt AC 1081 ms 12800 KB
04.txt AC 1073 ms 12800 KB
05.txt AC 1078 ms 12800 KB
06.txt AC 1074 ms 12800 KB
07.txt AC 1063 ms 12800 KB
08.txt AC 1108 ms 12800 KB
09.txt AC 1084 ms 12800 KB
10.txt AC 1068 ms 12800 KB
11.txt AC 2796 ms 4224 KB
12.txt AC 2804 ms 4096 KB
13.txt AC 497 ms 4864 KB
14.txt AC 499 ms 4864 KB
15.txt AC 509 ms 4864 KB
16.txt AC 503 ms 4864 KB
17.txt AC 102 ms 256 KB
18.txt AC 102 ms 256 KB
19.txt AC 102 ms 256 KB
20.txt AC 102 ms 256 KB
21.txt AC 1161 ms 7936 KB
22.txt AC 1189 ms 7936 KB
23.txt AC 1145 ms 7936 KB
24.txt AC 1143 ms 7936 KB
25.txt AC 1151 ms 7936 KB
26.txt AC 1151 ms 7808 KB
27.txt AC 225 ms 10624 KB
28.txt AC 15 ms 256 KB
29.txt AC 27 ms 256 KB
30.txt AC 21 ms 256 KB
31.txt AC 26 ms 256 KB
32.txt AC 25 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 103 ms 256 KB
35.txt AC 93 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt AC 2535 ms 5120 KB
38.txt AC 2568 ms 5120 KB
39.txt AC 2550 ms 5120 KB
40.txt AC 2549 ms 5120 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 4 ms 256 KB
44.txt AC 4 ms 256 KB
45.txt AC 4 ms 256 KB
46.txt AC 4 ms 256 KB
47.txt AC 4 ms 256 KB
48.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB
s3.txt AC 4 ms 256 KB