Submission #4277827
Source Code Expand
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
const LL INF = 1e11;
int N;
map<LL, int> cnt;
const LL L = 2155;
const int M = 100001;
bool is_composite[M];
vector<LL> ps, tris;
map<LL, LL> sq;
LL Reduce(LL v) {
for (LL p : tris) {
while (v%p == 0) v /= p;
}
return v;
}
LL Rev(LL v) {
LL ret = 1;
for (LL p : ps) {
int e = 0;
while (v%p == 0) {
e++;
v /= p;
}
assert(e <= 2);
if (e == 1) ret *= p*p;
else if (e == 2) ret *= p;
}
if (1 < v) {
assert(v > 2000);
if (sq.count(v)) v = sq[v];
else return -1;
ret *= v;
}
return ret;
}
int main() {
reps(i, 2, M) {
if (is_composite[i]) continue;
LL p = i;
if (p < L) {
ps.eb(p);
tris.eb(p*p*p);
} else {
sq[p*p] = p;
}
for (int j=i+i; j<M; j+=i) {
is_composite[j] = true;
}
}
//cout << ps.size() << endl;
scanf("%d", &N);
rep(i, N) {
LL s;
scanf("%lld", &s);
cnt[Reduce(s)]++;
}
int ans = N;
for (auto &p : cnt) {
LL v = p.X;
int a = p.Y;
//printf("%lld: %d\n", v, a);
LL r = Rev(v);
if (!cnt.count(r)) continue;
int b = cnt[r];
if (a > b) continue;
if (a == b && v < r) continue;
if (a == b && v == r) assert(v == 1);
//printf("removed (%lld,%d) because of (%lld, %d)\n", v, a, r, b);
ans -= a;
}
if (cnt.count(1)) ans++;
printf("%d\n", ans);
}
Submission Info
Submission Time |
|
Task |
D - Anticube |
User |
potetisensei |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2375 Byte |
Status |
WA |
Exec Time |
768 ms |
Memory |
7168 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:85:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
./Main.cpp:88:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &s);
^
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 |
764 ms |
7168 KB |
02.txt |
AC |
763 ms |
7168 KB |
03.txt |
AC |
756 ms |
7168 KB |
04.txt |
AC |
763 ms |
7168 KB |
05.txt |
AC |
755 ms |
7168 KB |
06.txt |
AC |
761 ms |
7168 KB |
07.txt |
AC |
763 ms |
7168 KB |
08.txt |
AC |
754 ms |
7168 KB |
09.txt |
AC |
768 ms |
7168 KB |
10.txt |
AC |
752 ms |
7168 KB |
11.txt |
AC |
476 ms |
2944 KB |
12.txt |
AC |
477 ms |
2944 KB |
13.txt |
WA |
502 ms |
3200 KB |
14.txt |
WA |
502 ms |
3200 KB |
15.txt |
WA |
503 ms |
3200 KB |
16.txt |
WA |
509 ms |
3200 KB |
17.txt |
AC |
368 ms |
896 KB |
18.txt |
AC |
368 ms |
896 KB |
19.txt |
AC |
368 ms |
896 KB |
20.txt |
AC |
369 ms |
896 KB |
21.txt |
WA |
604 ms |
4736 KB |
22.txt |
WA |
600 ms |
4736 KB |
23.txt |
WA |
604 ms |
4736 KB |
24.txt |
WA |
605 ms |
4736 KB |
25.txt |
WA |
606 ms |
4736 KB |
26.txt |
WA |
596 ms |
4736 KB |
27.txt |
AC |
699 ms |
6144 KB |
28.txt |
AC |
340 ms |
896 KB |
29.txt |
AC |
350 ms |
896 KB |
30.txt |
AC |
348 ms |
896 KB |
31.txt |
AC |
349 ms |
896 KB |
32.txt |
AC |
350 ms |
1024 KB |
33.txt |
AC |
3 ms |
896 KB |
34.txt |
AC |
364 ms |
896 KB |
35.txt |
AC |
364 ms |
896 KB |
36.txt |
AC |
3 ms |
896 KB |
37.txt |
AC |
512 ms |
3328 KB |
38.txt |
WA |
509 ms |
3328 KB |
39.txt |
AC |
508 ms |
3328 KB |
40.txt |
AC |
509 ms |
3328 KB |
41.txt |
AC |
3 ms |
896 KB |
42.txt |
AC |
3 ms |
896 KB |
43.txt |
AC |
3 ms |
896 KB |
44.txt |
AC |
3 ms |
896 KB |
45.txt |
AC |
3 ms |
896 KB |
46.txt |
AC |
3 ms |
896 KB |
47.txt |
AC |
3 ms |
896 KB |
48.txt |
AC |
3 ms |
896 KB |
s1.txt |
AC |
3 ms |
896 KB |
s2.txt |
AC |
3 ms |
896 KB |
s3.txt |
AC |
3 ms |
896 KB |