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

Submission #846605

Source Code Expand

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
for (auto i : a) cerr << i << ' ';\
cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

bool isPrime(int x) {
for (int i = 2; i * i <= x; ++i)
if (x % i == 0)
return false;
return true;
}

int main() {
int n;
scanf("%d", &n);
vector<ll> s(n);
forn(i, 0, n) scanf("%lld", &s[i]);
vector<int> primes;
forn(i, 2, 1e5 + 10)
if (isPrime(i))
primes.eb(i);
vector<ll> p2, p3;
for (int i : primes) p2.eb(1ll * i * i);
for (int i : primes) {
ll cb = 1ll * i * i * i;
if (cb < 1e10 + 10) p3.eb(cb);
else break;
}
map<ll, int> cnt;
for (ll x : s) {
for (ll j : p3) {
if (j > x) break;
while (x % j == 0) x /= j;
}
cnt[x]++;
}
ll ans = 0;
map<ll, char> used;
for (auto p : cnt) {
ll x = p.fs;
if (used.count(x)) continue;
if (x == 1) {
ans += 1;
} else {
used[x] = 1;
ll inv = 1;
forn(j, 0, p2.size()) {
if (p2[j] > x) break;
while (x % p2[j] == 0) {
x /= p2[j];
inv *= primes[j];
}
}
ld res = (ld)inv * x * x;
if (res > 2e10) {
ans += p.sn;
} else {
inv = inv * x * x;
used[inv] = 1;
auto ptr = cnt.find(inv);
if (ptr == cnt.end()) ans += p.sn;
else ans += max(p.sn, ptr->sn);
}
}
}
cout << ans << '\n';
return 0;
}
```

#### Submission Info

Submission Time 2016-08-21 21:41:18+0900 D - Anticube khadaev C++14 (GCC 5.4.1) 0 1847 Byte TLE 5254 ms 16640 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:37:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:39:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
forn(i, 0, n) scanf("%lld", &s[i]);
^
```

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
 AC × 3
 AC × 41 TLE × 10
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 TLE 5254 ms 11776 KB
02.txt TLE 5254 ms 11776 KB
03.txt TLE 5254 ms 11776 KB
04.txt TLE 5254 ms 11776 KB
05.txt TLE 5254 ms 11776 KB
06.txt TLE 5254 ms 11776 KB
07.txt TLE 5254 ms 11776 KB
08.txt TLE 5254 ms 11776 KB
09.txt TLE 5254 ms 11776 KB
10.txt TLE 5254 ms 11904 KB
11.txt AC 4042 ms 4992 KB
12.txt AC 4042 ms 4992 KB
13.txt AC 358 ms 6144 KB
14.txt AC 366 ms 6144 KB
15.txt AC 360 ms 6272 KB
16.txt AC 374 ms 6144 KB
17.txt AC 81 ms 1280 KB
18.txt AC 81 ms 1280 KB
19.txt AC 81 ms 1280 KB
20.txt AC 81 ms 1280 KB
21.txt AC 4643 ms 9216 KB
22.txt AC 4608 ms 9216 KB
23.txt AC 4669 ms 9216 KB
24.txt AC 4646 ms 9216 KB
25.txt AC 4628 ms 9216 KB
26.txt AC 4619 ms 9088 KB
27.txt AC 287 ms 16640 KB
28.txt AC 40 ms 1280 KB
29.txt AC 44 ms 1280 KB
30.txt AC 42 ms 1280 KB
31.txt AC 43 ms 1280 KB
32.txt AC 42 ms 1280 KB
33.txt AC 26 ms 512 KB
34.txt AC 75 ms 1280 KB
35.txt AC 74 ms 1280 KB
36.txt AC 26 ms 512 KB
37.txt AC 4331 ms 6016 KB
38.txt AC 4333 ms 6144 KB
39.txt AC 4327 ms 6016 KB
40.txt AC 4339 ms 6144 KB
41.txt AC 26 ms 512 KB
42.txt AC 26 ms 512 KB
43.txt AC 26 ms 512 KB
44.txt AC 26 ms 512 KB
45.txt AC 26 ms 512 KB
46.txt AC 26 ms 512 KB
47.txt AC 26 ms 512 KB
48.txt AC 26 ms 512 KB
s1.txt AC 26 ms 512 KB
s2.txt AC 26 ms 512 KB
s3.txt AC 26 ms 512 KB