Submission #4277682


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 int L = 2155;
bool is_composite[L];
vector<LL> ps, tris;

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 (ret >= INF/v) return -1;
  ret *= v;
  if (ret >= INF/v) return -1;
  ret *= v;
  return ret;
}

int main() {
  reps(i, 2, L) {
    if (is_composite[i]) continue;
    LL p = i;
    ps.eb(p);
    tris.eb(p*p*p);
    for (int j=i+i; j<L; 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 2244 Byte
Status WA
Exec Time 755 ms
Memory 6528 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:75:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
./Main.cpp:78: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
AC × 3
AC × 37
WA × 14
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 748 ms 6528 KB
02.txt AC 755 ms 6528 KB
03.txt AC 749 ms 6528 KB
04.txt AC 754 ms 6528 KB
05.txt AC 750 ms 6528 KB
06.txt AC 750 ms 6528 KB
07.txt AC 752 ms 6528 KB
08.txt AC 744 ms 6528 KB
09.txt AC 748 ms 6528 KB
10.txt AC 750 ms 6528 KB
11.txt AC 479 ms 2176 KB
12.txt AC 477 ms 2176 KB
13.txt WA 506 ms 2560 KB
14.txt WA 502 ms 2560 KB
15.txt WA 503 ms 2560 KB
16.txt WA 501 ms 2560 KB
17.txt AC 368 ms 256 KB
18.txt AC 368 ms 256 KB
19.txt AC 368 ms 256 KB
20.txt AC 368 ms 256 KB
21.txt WA 605 ms 4096 KB
22.txt WA 594 ms 4096 KB
23.txt WA 597 ms 4096 KB
24.txt WA 600 ms 4096 KB
25.txt WA 594 ms 4096 KB
26.txt WA 592 ms 4096 KB
27.txt AC 704 ms 5504 KB
28.txt AC 346 ms 256 KB
29.txt AC 349 ms 256 KB
30.txt AC 344 ms 256 KB
31.txt AC 342 ms 256 KB
32.txt AC 342 ms 256 KB
33.txt AC 1 ms 256 KB
34.txt AC 364 ms 256 KB
35.txt AC 363 ms 256 KB
36.txt AC 1 ms 256 KB
37.txt WA 505 ms 2688 KB
38.txt WA 510 ms 2688 KB
39.txt WA 506 ms 2688 KB
40.txt WA 506 ms 2688 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