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

Submission #846521

Source Code Expand

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

using namespace std;
#define mp make_pair
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
LL s[100005];
vector<pair<LL, LL> > all;

bool pr[2200];
vector<int> p;

const LL INF = 3e18;

map<LL, int> ma;
map<LL, LL> pp;

int main() {
forn(i, 2200) pr[i] = true;
pr[0] = pr[1] = false;
forn(i, 100) if (pr[i]) {
for (int j = i * i; j < 2200; j += i) {
pr[j] = false;
}
}
forn(i, 2200) if (pr[i]) {
p.pb(i);
}
scanf("%d", &n);
forn(i, n) scanf("%I64d", s + i);
int ans = n;
forn(i, n) {
LL inv = 1;
LL rem = s[i];
for (int j : p) {
LL cube = (LL)j * j * j;
while (s[i] % cube == 0) {
s[i] /= cube;
rem /= cube;
}
int cnt = 0;
while (s[i] % j == 0) {
s[i] /= j;
++cnt;
}
if (cnt == 1) {
if (inv > INF / j) inv = INF;
else inv *= j;
if (inv > INF / j) inv = INF;
else inv *= j;
} else if (cnt == 2) {
if (inv > INF / j) inv = INF;
else inv *= j;
}
}
if (s[i] > 1) {
int lo = 2, hi = 100000, mid;
while (lo < hi) {
mid = (lo + hi) >> 1;
if ((LL)mid * mid < s[i]) {
lo = mid + 1;
} else {
hi = mid;
}
}
if ((LL)lo * lo == s[i]) {
if (inv > INF / lo) inv = INF;
else inv *= lo;
} else {
if (inv > INF / s[i]) inv = INF;
else inv *= s[i];
if (inv > INF / s[i]) inv = INF;
else inv *= s[i];
}
}
if (inv <= 10000000000ll) {
all.pb(mp(rem, inv));
}
}
for (auto x : all) {
++ma[x.first];
pp[x.first] = x.second;
}
for (auto x : ma) {
if (x.first == 1) {
bad += 2 * (x.second - 1);
} else {
auto it = ma.find(pp[x.first]);
if (it != ma.end()) {
}
}
}
cout << ans << endl;
return 0;
}
```

#### Submission Info

Submission Time 2016-08-21 21:39:01+0900 D - Anticube HellKitsune C++14 (GCC 5.4.1) 0 2615 Byte WA 5253 ms 13044 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:34:36: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘LL* {aka long long int*}’ [-Wformat=]
forn(i, n) scanf("%I64d", s + i);
^
./Main.cpp:33:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:34:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
forn(i, n) scanf("%I64d", s + i);
^
```

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
 AC × 3
 AC × 33 WA × 5 TLE × 13
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 1253 ms 1024 KB
02.txt AC 1250 ms 1024 KB
03.txt AC 1252 ms 1024 KB
04.txt AC 1250 ms 1024 KB
05.txt AC 1250 ms 1024 KB
06.txt AC 1251 ms 1024 KB
07.txt AC 1252 ms 1024 KB
08.txt AC 1251 ms 1152 KB
09.txt AC 1251 ms 1024 KB
10.txt AC 1251 ms 1024 KB
11.txt AC 1244 ms 1024 KB
12.txt AC 1244 ms 1024 KB
13.txt WA 1223 ms 2940 KB
14.txt WA 1220 ms 2940 KB
15.txt WA 1220 ms 3068 KB
16.txt WA 1219 ms 2940 KB
17.txt TLE 5253 ms 1024 KB
18.txt TLE 5253 ms 1024 KB
19.txt TLE 5253 ms 1280 KB
20.txt TLE 5253 ms 1280 KB
21.txt TLE 5253 ms 1024 KB
22.txt TLE 5253 ms 1280 KB
23.txt TLE 5253 ms 1280 KB
24.txt TLE 5253 ms 1408 KB
25.txt TLE 5253 ms 1024 KB
26.txt TLE 5253 ms 1024 KB
27.txt AC 1366 ms 13044 KB
28.txt AC 1160 ms 3192 KB
29.txt AC 1165 ms 3192 KB
30.txt AC 1178 ms 3192 KB
31.txt AC 1181 ms 3192 KB
32.txt AC 1181 ms 3192 KB
33.txt AC 4 ms 256 KB
34.txt AC 1190 ms 1024 KB
35.txt AC 1202 ms 3192 KB
36.txt AC 4 ms 256 KB
37.txt TLE 5253 ms 1152 KB
38.txt TLE 5253 ms 1152 KB
39.txt TLE 5253 ms 1152 KB
40.txt WA 1250 ms 1280 KB
41.txt AC 4 ms 256 KB
42.txt AC 5 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