Submission #1515717
Source Code Expand
#include <bits/stdc++.h> #include <math.h> #define uint unsigned long long #define ll long long #define db double #define ls rt << 1 #define rs rt << 1 | 1 #define pb push_back #define mp make_pair #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define vi vector<int> #define vl vector<ll> #define rep(i, x, y) for(int i = x; i <= y; i ++) #define rrep(i, x, y) for(int i = x; i >= y; i --) #define eps 1e-9 using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } const int N = 100010; const int mod = 1e9 + 7; ll a[N], b[N], aa[N], bb[N]; map<ll, int> Mp; vector<int> p; bool vis[2010]; int main() { int n,ans = 0; rep(i, 2, 2000) if (!vis[i]) { p.push_back(i); for (int j = i + i; j < 2000; j += i) vis[j] = 1; } cin >> n; rep(i, 0, n - 1) { cin >> a[i]; b[i] = a[i]; } rep(i, 0, n - 1) { aa[i] = 1, bb[i] = 1; int nn = p.size(); rep(j, 0, nn - 1) { int cnt = 0; while (a[i] % p[j] == 0) { a[i] /= p[j]; cnt ++; } if (cnt % 3 == 1) aa[i] *= p[j], bb[i] *= p[j] * p[j]; else if (cnt % 3 == 2) bb[i] *= p[j], aa[i] *= p[j] * p[j]; } aa[i] *= a[i]; ll t = floor(sqrt(a[i] * 1.0)); if (t * t == a[i]) bb[i] *= t; else { if (bb[i] * a[i] > 0 && bb[i] * a[i] * a[i] > 0) bb[i] *= a[i] * a[i]; else bb[i] = 0; } Mp[aa[i]] ++; } int flag = 0; rep(i, 0, n - 1) { if (aa[i] == 1) { if (flag == 0) ans ++, flag = 1; } else ans += max(Mp[aa[i]], Mp[bb[i]]), Mp[aa[i]] = Mp[bb[i]] = 0; } cout << ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | lzr156 |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 2124 Byte |
Status | AC |
Exec Time | 477 ms |
Memory | 14464 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 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 | 475 ms | 14336 KB |
02.txt | AC | 475 ms | 14336 KB |
03.txt | AC | 476 ms | 14336 KB |
04.txt | AC | 476 ms | 14336 KB |
05.txt | AC | 476 ms | 14464 KB |
06.txt | AC | 476 ms | 14336 KB |
07.txt | AC | 477 ms | 14464 KB |
08.txt | AC | 476 ms | 14464 KB |
09.txt | AC | 476 ms | 14336 KB |
10.txt | AC | 476 ms | 14464 KB |
11.txt | AC | 428 ms | 6528 KB |
12.txt | AC | 428 ms | 6528 KB |
13.txt | AC | 431 ms | 7296 KB |
14.txt | AC | 431 ms | 7296 KB |
15.txt | AC | 432 ms | 7296 KB |
16.txt | AC | 432 ms | 7296 KB |
17.txt | AC | 405 ms | 3328 KB |
18.txt | AC | 405 ms | 3328 KB |
19.txt | AC | 405 ms | 3328 KB |
20.txt | AC | 405 ms | 3328 KB |
21.txt | AC | 450 ms | 10112 KB |
22.txt | AC | 449 ms | 10112 KB |
23.txt | AC | 450 ms | 10240 KB |
24.txt | AC | 450 ms | 10112 KB |
25.txt | AC | 449 ms | 10112 KB |
26.txt | AC | 449 ms | 10112 KB |
27.txt | AC | 434 ms | 13696 KB |
28.txt | AC | 333 ms | 3328 KB |
29.txt | AC | 337 ms | 3328 KB |
30.txt | AC | 339 ms | 3328 KB |
31.txt | AC | 345 ms | 3328 KB |
32.txt | AC | 344 ms | 3328 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 404 ms | 3328 KB |
35.txt | AC | 398 ms | 3328 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 434 ms | 7424 KB |
38.txt | AC | 438 ms | 7424 KB |
39.txt | AC | 434 ms | 7424 KB |
40.txt | AC | 435 ms | 7424 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 1 ms | 256 KB |
44.txt | AC | 1 ms | 256 KB |
45.txt | AC | 1 ms | 256 KB |
46.txt | AC | 1 ms | 256 KB |
47.txt | AC | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |