Submission #846175


Source Code Expand

Copy
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#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 repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(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;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
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;

//素因数分解
vector<int> primes,prime;
class PRPRPR{
public:
  PRPRPR(int PRIME_MAX){
    prime.resize(PRIME_MAX);
    for(int i=2;i<PRIME_MAX;i++)if(!prime[i]){
	primes.pb(i);
	for(int j=i*2;j<PRIME_MAX;j+=i)
	  prime[j]=1;
      }
  }
} prprprpr(2200);

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  unordered_map<ll,pll> cnts;
  for(ll x:a){
    ll key=1,co=1;
    for(int p:primes){
      if(x%p) continue;
      int cnt=0;
      while(x%p==0){
	++cnt;
	x/=p;
      }
      cnt%=3;
      if(!cnt){
	continue;
      }else if(cnt==1){
	key*=p;
	co*=1ll*p*p;
      }else{
	key*=1ll*p*p;
	co*=p;
      }
    }
    if(x>1){
      ll tmp=sqrt(x);
      ll f=0;
      reps(i,-1,2) if((tmp+i)*(tmp+i)==x) f=tmp+i;
      if(f){
	key*=x;
	co*=f;
      }else{
	key*=x;
	co*=x*x;
      }
    }
    cnts[key].Y=co;
    ++cnts[key].X;
  }
  auto tmp=cnts;
  ll re=0;
  for(auto p:tmp) if(p.X!=1 && cnts[p.Y.Y]<p.Y) re+=p.Y.X;
  //for(auto p:tmp) if(p.X!=1 && cnts[p.Y.Y]<p.Y) cout<<p;
  re+=!!cnts[1].X;
  cout<<re<<endl;
  return 0;
}

Submission Info

Submission Time
Task D - Anticube
User nuip
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 2658 Byte
Status AC
Exec Time 793 ms
Memory 18120 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1100 / 1100
Status
AC × 3
AC × 51
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 695 ms 18120 KB
02.txt AC 698 ms 18120 KB
03.txt AC 695 ms 18120 KB
04.txt AC 696 ms 18120 KB
05.txt AC 698 ms 18120 KB
06.txt AC 694 ms 18120 KB
07.txt AC 694 ms 18120 KB
08.txt AC 694 ms 18120 KB
09.txt AC 693 ms 18120 KB
10.txt AC 714 ms 18120 KB
11.txt AC 625 ms 7436 KB
12.txt AC 618 ms 7436 KB
13.txt AC 617 ms 7692 KB
14.txt AC 619 ms 7692 KB
15.txt AC 619 ms 7692 KB
16.txt AC 623 ms 7692 KB
17.txt AC 793 ms 1152 KB
18.txt AC 654 ms 1024 KB
19.txt AC 654 ms 1024 KB
20.txt AC 654 ms 1024 KB
21.txt AC 664 ms 11044 KB
22.txt AC 662 ms 11044 KB
23.txt AC 663 ms 11044 KB
24.txt AC 665 ms 11044 KB
25.txt AC 666 ms 11044 KB
26.txt AC 668 ms 11044 KB
27.txt AC 666 ms 15688 KB
28.txt AC 579 ms 1024 KB
29.txt AC 589 ms 1024 KB
30.txt AC 588 ms 1024 KB
31.txt AC 590 ms 1024 KB
32.txt AC 590 ms 1024 KB
33.txt AC 4 ms 256 KB
34.txt AC 655 ms 1024 KB
35.txt AC 647 ms 1024 KB
36.txt AC 4 ms 256 KB
37.txt AC 640 ms 7972 KB
38.txt AC 630 ms 7972 KB
39.txt AC 628 ms 7972 KB
40.txt AC 630 ms 7972 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 4 ms 256 KB
44.txt AC 4 ms 256 KB
45.txt AC 4 ms 256 KB
46.txt AC 4 ms 256 KB
47.txt AC 4 ms 256 KB
48.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB
s3.txt AC 4 ms 256 KB