Contest Duration: - (local time) (110 minutes) Back to Home

Submission #848423

Source Code Expand

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define INF 10000000010LL

int p[1000], pb[1000], L; ll pc[1000];
int n; map<ll, int> F; map<ll, ll> ra;
set<ll> C;

int main () {
for (int i = 2; i < 3000; i ++) {
bool F = 1;
for (int j = 2; j*j <= i; j ++)
if (i%j == 0) {F = 0; break;}
if (F) {
p[L] = i;
pb[L] = i*i;
pc[L] = (ll)i*i*i;
L ++;
}
}
cin >> n;
int S = 0;
bool F1 = 0;
for (int i = 0; i < n; i ++) {
ll x;
cin >> x;
ll y = 1;
ll x1 = 1;
for (int j = 0; x != x1 && j < L; j ++) {
while (x%pc[j] == 0) {
x /= pc[j];
}
if (x%pb[j] == 0) {
y *= p[j];
x1 *= pb[j];
if (y > INF) y = INF;
} else
if (x%p[j] == 0) {
y *= pb[j];
x1 *= p[j];
if (y > INF) y = INF;
}
}
x /= x1;
if (y >= INF) {
S ++; continue;
}
if (x != 1) {
int c = sqrt(x); int cc = -1;
for (int d = max(1, c-10); d <= c+10; d ++)
if ((ll)d*d == x) {
cc = d; break;
}
if (cc == -1) {
if (INF/x/x < y) {S ++; continue;}
y *= x; y *= x;
} else {
y *= cc;
}
}
if (y >= INF) {
S ++; continue;
}
x *= x1;
if (x == 1) {
if (!F1) {
F1 = 1;
S ++;
}
continue;
}
F[x] ++;
ra[x] = y;
}

for (map<ll,int>::iterator i = F.begin(); i != F.end(); i ++) {
ll r = ra[i->fi];
if (i->fi < r || F.find(r) == F.end()) {
S += max(i->se, F[r]);
}
}
cout << S << endl;
return 0;
}```

#### Submission Info

Submission Time 2016-08-21 22:50:12+0900 D - Anticube sevenkplus C++14 (GCC 5.4.1) 1100 1673 Byte AC 2293 ms 20864 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 2182 ms 256 KB
02.txt AC 2186 ms 256 KB
03.txt AC 2179 ms 256 KB
04.txt AC 2181 ms 256 KB
05.txt AC 2180 ms 256 KB
06.txt AC 2183 ms 256 KB
07.txt AC 2179 ms 256 KB
08.txt AC 2180 ms 256 KB
09.txt AC 2196 ms 256 KB
10.txt AC 2180 ms 256 KB
11.txt AC 2262 ms 256 KB
12.txt AC 2253 ms 256 KB
13.txt AC 2263 ms 2432 KB
14.txt AC 2293 ms 2432 KB
15.txt AC 2260 ms 2432 KB
16.txt AC 2259 ms 2432 KB
17.txt AC 123 ms 256 KB
18.txt AC 123 ms 256 KB
19.txt AC 124 ms 256 KB
20.txt AC 123 ms 256 KB
21.txt AC 1720 ms 1408 KB
22.txt AC 1715 ms 1408 KB
23.txt AC 1714 ms 1408 KB
24.txt AC 1714 ms 1408 KB
25.txt AC 1712 ms 1408 KB
26.txt AC 1710 ms 1408 KB
27.txt AC 1382 ms 20864 KB
28.txt AC 31 ms 256 KB
29.txt AC 41 ms 256 KB
30.txt AC 48 ms 256 KB
31.txt AC 49 ms 256 KB
32.txt AC 49 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 123 ms 256 KB
35.txt AC 116 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt AC 2168 ms 512 KB
38.txt AC 2163 ms 512 KB
39.txt AC 2162 ms 512 KB
40.txt AC 2164 ms 512 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