Submission #846668
Source Code Expand
Copy
#include <cstdio> #include <cstdlib> #include <cassert> #include <iostream> #include <set> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <numeric> #include <cmath> #include <complex> #include <map> #include <queue> #include <array> #include <bitset> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<double, double> pdd; typedef vector<string> vs; int main() { vi erat(1000000, 1); erat[0] = erat[1] = 0; for (int i = 2; i * i < erat.size(); ++i) if (erat[i]) { for (int j = i * i; j < erat.size(); j += i) erat[j] = 0; } int n; scanf("%d", &n); vi p; for (int i = 2; i <= 2500; ++i) { p.push_back(i); for (int j = 2; j * j <= i; ++j) if (i % j == 0) { p.pop_back(); break; } } vl p3; for (ll d : p) p3.push_back(d*d*d); int was1 = 0; vl a; for (int i = 0; i < n; ++i) { ll x; scanf("%lld", &x); for (ll d3 : p3) { if (d3 > x) break; while (x % d3 == 0) x /= d3; } if (x == 1) { was1 = 1; } else { a.push_back(x); } } sort(a.begin(), a.end()); if (a.empty()) { cout << was1 << endl; return 0; } vl v(1, a[0]); vi c(1, 1); for (int i = 1; i < a.size(); ++i) { if (a[i] == a[i-1]) ++c.back(); else { v.push_back(a[i]); c.push_back(1); } } vi was(v.size()); int res = was1; // cerr << was1 << endl; for (int i = 0; i < v.size(); ++i) if (!was[i]) { // cerr << v[i] << ' ' << c[i] << endl; was[i] = 1; ll r = 1; ll val = v[i]; for (int it = 0; it < p.size() && p3[it] <= val; ++it) if (val % p[it] == 0) { ll mul = p3[it]; while (val % p[it] == 0) { val /= p[it]; mul /= p[it]; } if (r <= 1e15 / mul) r *= mul; } if (val > 1) { ll sq = sqrt(val); while (sq * sq < val) ++sq; while (sq * sq > val) --sq; if (sq * sq == val) { assert(erat[sq]); val = 1; if (r <= 1e15 / sq) r *= sq; } } if (val > 1 && val <= 1000000) { ll mul = val * val; if (r <= 1e15 / mul) r *= mul; val = 1; } if (val > 1 || !binary_search(v.begin(), v.end(), r)) { res += c[i]; } else { int it = lower_bound(v.begin(), v.end(), r) - v.begin(); was[it] = 1; res += max(c[i], c[it]); } } printf("%d\n", res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | ariacas |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2648 Byte |
Status | WA |
Exec Time | 643 ms |
Memory | 6780 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:35:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &x); ^
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 | AC | 640 ms | 6780 KB |
02.txt | AC | 640 ms | 6780 KB |
03.txt | AC | 639 ms | 6780 KB |
04.txt | AC | 639 ms | 6780 KB |
05.txt | AC | 641 ms | 6780 KB |
06.txt | AC | 643 ms | 6780 KB |
07.txt | AC | 639 ms | 6780 KB |
08.txt | AC | 642 ms | 6780 KB |
09.txt | AC | 643 ms | 6780 KB |
10.txt | AC | 642 ms | 6780 KB |
11.txt | AC | 624 ms | 5500 KB |
12.txt | AC | 624 ms | 5500 KB |
13.txt | AC | 141 ms | 5756 KB |
14.txt | AC | 143 ms | 5756 KB |
15.txt | AC | 142 ms | 5756 KB |
16.txt | AC | 143 ms | 5756 KB |
17.txt | AC | 75 ms | 5248 KB |
18.txt | AC | 75 ms | 5376 KB |
19.txt | AC | 75 ms | 5376 KB |
20.txt | AC | 75 ms | 5376 KB |
21.txt | WA | 425 ms | 5884 KB |
22.txt | WA | 424 ms | 5884 KB |
23.txt | WA | 424 ms | 5884 KB |
24.txt | WA | 425 ms | 5884 KB |
25.txt | WA | 427 ms | 5884 KB |
26.txt | WA | 427 ms | 5884 KB |
27.txt | AC | 92 ms | 6652 KB |
28.txt | AC | 29 ms | 4224 KB |
29.txt | AC | 35 ms | 4224 KB |
30.txt | AC | 38 ms | 5248 KB |
31.txt | AC | 38 ms | 5376 KB |
32.txt | AC | 38 ms | 5376 KB |
33.txt | AC | 17 ms | 4096 KB |
34.txt | AC | 71 ms | 5376 KB |
35.txt | AC | 64 ms | 4096 KB |
36.txt | AC | 17 ms | 4224 KB |
37.txt | WA | 600 ms | 5756 KB |
38.txt | WA | 600 ms | 5756 KB |
39.txt | WA | 599 ms | 5756 KB |
40.txt | WA | 600 ms | 5756 KB |
41.txt | AC | 17 ms | 4096 KB |
42.txt | AC | 16 ms | 4096 KB |
43.txt | AC | 17 ms | 4096 KB |
44.txt | AC | 17 ms | 4096 KB |
45.txt | AC | 17 ms | 4096 KB |
46.txt | AC | 17 ms | 4224 KB |
47.txt | AC | 17 ms | 4096 KB |
48.txt | AC | 17 ms | 4096 KB |
s1.txt | AC | 17 ms | 4096 KB |
s2.txt | AC | 17 ms | 4096 KB |
s3.txt | AC | 17 ms | 4096 KB |