Submission #847652
Source Code Expand
Copy
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int M = 100100; bool u[M]; int m = 0, p[M]; ll sq[M], cb[M]; void sito() { for (int i = 2; i < M; ++i) if (!u[i]) { p[m++] = i; for (int j = i; j < M; j += i) u[j] = true; } copy(p, p + m, sq); copy(p, p + m, cb); for (int i = 0; i < M; ++i) { sq[i] *= p[i]; cb[i] *= sq[i]; } //cerr << "m = " << m << endl; } int n; ll a[M]; map<pair<ll, ll>, int> cnt; void read() { cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; } void kill() { for (int i = 0; i < n; ++i) for (int j = 0; cb[j] <= a[i]; ++j) while (a[i] % cb[j] == 0) { a[i] /= cb[j]; } bool is_cube = false; int sum = 0; for (int i = 0; i < n; ++i) { ll A = a[i]; if (A == 1) { is_cube = true; continue; } ll B = 1; for (int j = 0; sq[j] <= A; ++j) if (A % sq[j] == 0) { A /= sq[j]; B *= p[j]; } //cerr << A << " " << B << endl; int val = 1; if (A > B) { swap(A, B); val = -1; } cnt[make_pair(A, B)] += val; sum++; } int ans = 0; ans += sum; for (auto x : cnt) ans += abs(x.second); ans /= 2; if (is_cube) ++ans; cout << ans << endl; } int main() { cout.precision(20); cout << fixed; ios_base::sync_with_stdio(false); sito(); read(); kill(); }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | Arterm |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1547 Byte |
Status | TLE |
Exec Time | 5258 ms |
Memory | 7936 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1100 | ||||||
Status |
|
|
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 | 5257 ms | 6528 KB |
02.txt | TLE | 5257 ms | 6528 KB |
03.txt | TLE | 5257 ms | 6528 KB |
04.txt | TLE | 5257 ms | 6528 KB |
05.txt | TLE | 5257 ms | 6528 KB |
06.txt | TLE | 5257 ms | 6528 KB |
07.txt | TLE | 5257 ms | 6528 KB |
08.txt | TLE | 5257 ms | 6528 KB |
09.txt | TLE | 5258 ms | 6528 KB |
10.txt | TLE | 5257 ms | 6528 KB |
11.txt | TLE | 5257 ms | 4224 KB |
12.txt | TLE | 5257 ms | 4224 KB |
13.txt | AC | 1408 ms | 4736 KB |
14.txt | AC | 1419 ms | 4736 KB |
15.txt | AC | 1429 ms | 4736 KB |
16.txt | AC | 1435 ms | 4736 KB |
17.txt | AC | 71 ms | 2688 KB |
18.txt | AC | 70 ms | 2688 KB |
19.txt | AC | 70 ms | 2688 KB |
20.txt | AC | 70 ms | 2688 KB |
21.txt | TLE | 5257 ms | 6400 KB |
22.txt | TLE | 5257 ms | 6400 KB |
23.txt | TLE | 5257 ms | 6400 KB |
24.txt | TLE | 5257 ms | 6528 KB |
25.txt | TLE | 5257 ms | 6400 KB |
26.txt | TLE | 5257 ms | 6400 KB |
27.txt | AC | 143 ms | 7936 KB |
28.txt | AC | 21 ms | 2688 KB |
29.txt | AC | 26 ms | 2688 KB |
30.txt | AC | 29 ms | 2688 KB |
31.txt | AC | 28 ms | 2688 KB |
32.txt | AC | 28 ms | 2688 KB |
33.txt | AC | 10 ms | 1920 KB |
34.txt | AC | 62 ms | 2688 KB |
35.txt | AC | 56 ms | 2688 KB |
36.txt | AC | 10 ms | 1920 KB |
37.txt | TLE | 5257 ms | 4480 KB |
38.txt | TLE | 5257 ms | 4480 KB |
39.txt | TLE | 5257 ms | 4608 KB |
40.txt | TLE | 5257 ms | 4480 KB |
41.txt | AC | 10 ms | 1920 KB |
42.txt | AC | 10 ms | 1920 KB |
43.txt | AC | 10 ms | 1920 KB |
44.txt | AC | 10 ms | 1920 KB |
45.txt | AC | 10 ms | 1920 KB |
46.txt | AC | 10 ms | 1920 KB |
47.txt | AC | 10 ms | 1920 KB |
48.txt | AC | 10 ms | 1920 KB |
s1.txt | AC | 10 ms | 1920 KB |
s2.txt | AC | 10 ms | 1920 KB |
s3.txt | AC | 10 ms | 1920 KB |