Submission #847151


Source Code Expand

Copy
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

const int limit=3000;
bool isprime[limit+1];
vector<ll> prime;

void init(){
	rep(i,limit+1) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*i;j<=limit;j+=i)
				isprime[j]=false;
		}
	}
	return;
}

map<ll,int> cnt;
map<ll,ll> comp;

int main(void){
	init();
	const int m=prime.size();

	int n;
	cin >> n;
	rep(i,n){
		ll cur,tar=1LL;
		cin >> cur;

		rep(j,m){
			ll sq=1LL*prime[j]*prime[j];
			ll cube=1LL*prime[j]*prime[j]*prime[j];
			while(cur%cube==0) cur/=cube;

			if(cur%sq==0)
				tar*=prime[j];
			else if(cur%prime[j]==0)
				tar*=sq;
		}
		cnt[cur]++;
		comp[cur]=tar;
	}

	ll ans=0LL;

	/*
	for(auto &it:cnt){
		cout << it.first << " " << it.second << " " << comp[it.first] << endl;
	}
	*/

	for(auto &it:cnt){
		if(it.first==1)
			ans+=min<ll>(1LL,it.second);
		else
			ans+=max<ll>(it.second,cnt[comp[it.first]]);
		it.second=0LL;
		cnt[comp[it.first]]=0LL;
	}
	cout << ans << endl;
	return 0;	
}

Submission Info

Submission Time
Task D - Anticube
User Hec
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1942 Byte
Status WA
Exec Time 398 ms
Memory 13056 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 36
WA × 15
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 396 ms 13056 KB
02.txt AC 393 ms 13056 KB
03.txt AC 398 ms 13056 KB
04.txt AC 392 ms 13056 KB
05.txt AC 397 ms 13056 KB
06.txt AC 368 ms 13056 KB
07.txt AC 389 ms 13056 KB
08.txt AC 386 ms 13056 KB
09.txt AC 392 ms 13056 KB
10.txt AC 394 ms 13056 KB
11.txt AC 294 ms 4096 KB
12.txt AC 297 ms 4096 KB
13.txt WA 279 ms 4864 KB
14.txt WA 265 ms 4864 KB
15.txt WA 262 ms 4864 KB
16.txt WA 265 ms 4864 KB
17.txt AC 221 ms 256 KB
18.txt AC 218 ms 256 KB
19.txt AC 216 ms 256 KB
20.txt AC 221 ms 256 KB
21.txt WA 321 ms 8064 KB
22.txt WA 319 ms 7936 KB
23.txt WA 321 ms 8064 KB
24.txt WA 319 ms 7936 KB
25.txt WA 318 ms 7936 KB
26.txt WA 320 ms 7936 KB
27.txt WA 341 ms 11136 KB
28.txt AC 112 ms 256 KB
29.txt AC 113 ms 256 KB
30.txt AC 120 ms 256 KB
31.txt AC 120 ms 256 KB
32.txt AC 120 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 236 ms 256 KB
35.txt AC 226 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt WA 304 ms 5120 KB
38.txt WA 302 ms 5120 KB
39.txt WA 303 ms 5120 KB
40.txt WA 302 ms 5120 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