Submission #1687348


Source Code Expand

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 100005;

LL a[maxn],t[maxn];int n,cnt,m,ans;
int prm[maxn],tot,is[maxn],ord[maxn];

void predo(int n) {
	for (int i=2;i<=n;i++)
	{
		if (!is[i]) prm[++tot]=i;
		for (int j=1;j<=tot;j++)
		{
			int num=prm[j]*i;
			if (num>n) break;
			if (i%prm[j]) is[num]=1;
			else {is[num]=1;break;}
		}
	}
}
void solve(LL n)
{
	LL u=1ll,v=1ll;
	for (int i=1;i<=tot;i++)
	if (n%prm[i]==0) {
		int cnt=0,x=prm[i];
		while (n%x==0) n/=x,++cnt;
		cnt%=3;
		if (cnt==1) u*=x,v*=x*x;
		if (cnt==2) u*=x*x,v*=x;
	}
	LL n_=sqrt(n);
	if (n_*n_==n) u*=n,v*=n_;
	else if (n>(int)1e5) {ans++;return ;}
	else {u*=n;v*=n*n;}
	if (u==1) ++cnt;
	else {t[++m]=min(u,v);a[m]=v;}
}

bool comp(int x,int y) {return t[x]<t[y];}
int main()
{
	#ifdef Amberframe
		freopen("agc003d.in","r",stdin);
		freopen("agc003d.out","w",stdout);
	#endif
	scanf("%d",&n);predo((int)2200);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++) solve(a[i]);
	for (int i=1;i<=m;i++) ord[i]=i;
	sort(ord+1,ord+m+1,comp);
	
	for (int i=1;i<=m;)
	{
		int pos=i,c1=0,c2=0;
		while (pos<=n&&t[ord[pos]]==t[ord[i]]) {
			a[ord[pos]]==a[ord[i]]?c1++:c2++;++pos;
		}
		ans+=max(c1,c2);i=pos;
	}
	printf("%d",ans+(cnt?1:0));
	return 0;
}

Submission Info

Submission Time
Task D - Anticube
User Amberframe
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1419 Byte
Status CE

Compile Error

./Main.cpp: In function ‘void solve(LL)’:
./Main.cpp:38:14: error: ‘sqrt’ was not declared in this scope
  LL n_=sqrt(n);
              ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:53:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);predo((int)2200);
                ^
./Main.cpp:54:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
                                            ^