Submission #4298388


Source Code Expand

/*input
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#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())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

vector<ll> p;
bool isp[maxn];

map<ll,ll> mp;

ll a[maxn];

ll nocube(ll x){
	for(ll i:p){
		if(i*i*i>x) break;
		while(x%(i*i*i)==0) x/=(i*i*i);
	}
	return x;
}

map<ll,ll> cnt;

set<ll> vis;
int main()
{
	IOS;

	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=0;
			if(i%p[j]==0) break;
		}
	}
	for(ll i:p){
		if(i*i*i>1000000000LL){
			ll d=i*i;
			for(ll j=d;j<maxn;j+=d) mp[d]=i;
		}
	}

	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) a[i]=nocube(a[i]);
	// REP(i,n) cout<<a[i]<<" \n"[i==n-1];
	bool flag=0;
	REP(i,n){
		if(a[i]>1) cnt[a[i]]++;
		else flag=1;
	}
	ll ans=0;
	for(auto i:cnt){
		ll type=i.F;
		if(vis.count(type)) continue;
		vis.insert(type);
		__int128 tmp=type*type;
		if(mp.count(type)){
			ll pp=mp[type];
			tmp/=pp*pp*pp;
		}
		for(ll i:p){
			if(i*i*i>10000000000LL) break;

			while(type%(i*i)==0) tmp/=(i*i*i);
		}
		// cout<<type<<' '<<(ll)tmp<<'\n';
		if(tmp<10000000005LL&&cnt.count((ll)tmp)){
			ans+=max(i.S,cnt[tmp]);
			vis.insert(tmp);
		}
		else ans+=i.S;
	}
	cout<<ans+flag<<'\n';
	return 0;
}

Submission Info

Submission Time
Task D - Anticube
User iloveUtaha
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2449 Byte
Status TLE
Exec Time 5256 ms
Memory 10228 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 18
TLE × 33
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 TLE 5255 ms 10228 KB
02.txt TLE 5256 ms 8180 KB
03.txt TLE 5256 ms 8180 KB
04.txt TLE 5256 ms 8180 KB
05.txt TLE 5256 ms 8180 KB
06.txt TLE 5256 ms 8180 KB
07.txt TLE 5256 ms 8180 KB
08.txt TLE 5256 ms 8180 KB
09.txt TLE 5256 ms 8180 KB
10.txt TLE 5256 ms 8180 KB
11.txt AC 2480 ms 5364 KB
12.txt AC 2475 ms 5364 KB
13.txt TLE 5255 ms 4212 KB
14.txt TLE 5255 ms 4212 KB
15.txt TLE 5255 ms 4212 KB
16.txt TLE 5255 ms 4212 KB
17.txt TLE 5255 ms 2036 KB
18.txt TLE 5255 ms 2036 KB
19.txt TLE 5255 ms 2036 KB
20.txt TLE 5255 ms 2036 KB
21.txt TLE 5256 ms 5748 KB
22.txt TLE 5255 ms 7796 KB
23.txt TLE 5255 ms 7796 KB
24.txt TLE 5256 ms 5748 KB
25.txt TLE 5256 ms 5748 KB
26.txt TLE 5255 ms 7796 KB
27.txt TLE 5256 ms 7156 KB
28.txt AC 10 ms 2036 KB
29.txt AC 12 ms 2036 KB
30.txt TLE 5255 ms 2036 KB
31.txt TLE 5255 ms 2036 KB
32.txt TLE 5255 ms 2036 KB
33.txt AC 4 ms 1528 KB
34.txt AC 31 ms 2036 KB
35.txt AC 30 ms 2036 KB
36.txt AC 4 ms 1528 KB
37.txt TLE 5255 ms 4340 KB
38.txt TLE 5255 ms 4340 KB
39.txt TLE 5255 ms 4340 KB
40.txt TLE 5255 ms 4340 KB
41.txt AC 4 ms 1528 KB
42.txt AC 4 ms 1528 KB
43.txt AC 4 ms 1528 KB
44.txt AC 4 ms 1528 KB
45.txt AC 4 ms 1528 KB
46.txt AC 4 ms 1528 KB
47.txt TLE 5255 ms 1528 KB
48.txt AC 4 ms 1528 KB
s1.txt AC 4 ms 1528 KB
s2.txt AC 4 ms 1528 KB
s3.txt AC 4 ms 1528 KB