Submission #9294859


Source Code Expand

Copy
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e5+10;
int p[SIZE];
vector<int>pp;
void prime_init(){
    for(int i=2;i<SIZE;i++){
        if(!p[i]){
            pp.PB(i);
            for(int j=i;j<SIZE;j+=i){
                if(!p[j])p[j]=i;
            }
        }
    }
}
bool is_prime(int x){
    return p[x]==x;
}
int one_cnt;
int an;
VPLL d;
void go(LL x){
    LL v=pow((LD)x,1./3);
    while(v*v*v<x)v++;
    if(v*v*v==x){
        one_cnt++;
        return;
    }
    LL inv=1;
    LL me=1;
    for(int i=0;pp[i]*pp[i]*pp[i]<=x;i++){
        if(x%pp[i]==0){
            int cnt=1;
            x/=pp[i];
            while(x%pp[i]==0){
                cnt++;
                x/=pp[i];
            }
            cnt%=3;
            if(cnt==1){
                inv*=pp[i]*pp[i];
                if(inv>10000000000LL){
                    an++;
                    return;
                }
                me*=pp[i];
            }
            else if(cnt==2){
                inv*=pp[i];
                if(inv>10000000000LL){
                    an++;
                    return;
                }
                me*=pp[i]*pp[i];
            }
        }
    }
    if(x!=1){
        LL v=sqrt((LD)x);
        if(v*v==x){
            me*=x;
            inv*=v;
        }
        else{
            me*=x;
            if(inv>10000000000LL/x*x){
                an++;
                return;
            }
            inv*=x*x;
        }
    }
    if(inv>10000000000LL){
        an++;
        return;
    }
    if(me<inv){
        d.PB(MP(me,1));
    }
    else{
        d.PB(MP(inv,0));
    }
}
int main(){
    prime_init();
    int N;
    R(N);
    REP(i,N){
        LL x;
        R(x);
        go(x);
    }
    sort(ALL(d));
    for(int i=0,j;i<SZ(d);i=j){
        int cnt[2]={};
        for(j=i;j<SZ(d)&&d[j].F==d[i].F;j++){
            cnt[d[j].S]++;
        }
        an+=max(cnt[0],cnt[1]);
    }
    an+=(one_cnt>0);
    W(an);
    return 0;
}

Submission Info

Submission Time
Task D - Anticube
User dreamoon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 4505 Byte
Status RE
Exec Time 326 ms
Memory 2872 KB

Compile Error

./Main.cpp: In function ‘void _R(int&)’:
./Main.cpp:45:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(int &x) { scanf("%d", &x); }
                                  ^
./Main.cpp: In function ‘void _R(LL&)’:
./Main.cpp:46:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(LL &x) { scanf("%lld", &x); }
                                   ^
./Main.cpp: In function ‘void _R(double&)’:
./Main.cpp:47:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(double &x) { scanf("%lf", &x); }
                                      ^
./Main.cpp: In function ‘void _R(char&)’:
./Main.cpp:48:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 void _R(char &x) { scanf(" %c", &x); }
     ...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 25
RE × 26
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 RE 98 ms 1152 KB
02.txt RE 97 ms 768 KB
03.txt RE 96 ms 768 KB
04.txt RE 96 ms 768 KB
05.txt RE 97 ms 768 KB
06.txt RE 97 ms 768 KB
07.txt RE 96 ms 768 KB
08.txt RE 96 ms 768 KB
09.txt RE 96 ms 768 KB
10.txt RE 97 ms 768 KB
11.txt RE 97 ms 768 KB
12.txt RE 96 ms 768 KB
13.txt RE 326 ms 1152 KB
14.txt RE 109 ms 768 KB
15.txt RE 97 ms 768 KB
16.txt RE 278 ms 1024 KB
17.txt AC 87 ms 2872 KB
18.txt AC 87 ms 2872 KB
19.txt AC 87 ms 2872 KB
20.txt AC 87 ms 2872 KB
21.txt RE 97 ms 768 KB
22.txt RE 97 ms 768 KB
23.txt RE 97 ms 768 KB
24.txt RE 96 ms 768 KB
25.txt RE 96 ms 768 KB
26.txt RE 96 ms 768 KB
27.txt AC 62 ms 2872 KB
28.txt AC 39 ms 768 KB
29.txt AC 36 ms 768 KB
30.txt AC 45 ms 2872 KB
31.txt AC 46 ms 2872 KB
32.txt AC 46 ms 2872 KB
33.txt AC 2 ms 768 KB
34.txt AC 88 ms 2872 KB
35.txt AC 44 ms 768 KB
36.txt AC 2 ms 768 KB
37.txt RE 97 ms 768 KB
38.txt RE 96 ms 768 KB
39.txt RE 97 ms 768 KB
40.txt RE 97 ms 768 KB
41.txt AC 2 ms 768 KB
42.txt AC 2 ms 768 KB
43.txt AC 2 ms 768 KB
44.txt AC 2 ms 768 KB
45.txt AC 2 ms 768 KB
46.txt AC 2 ms 768 KB
47.txt AC 2 ms 768 KB
48.txt AC 2 ms 768 KB
s1.txt AC 2 ms 768 KB
s2.txt AC 2 ms 768 KB
s3.txt AC 2 ms 768 KB