Submission #846386


Source Code Expand

Copy
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define SIZE 100005

using namespace std;
typedef long long int ll;

map <ll,int> mp;
map <ll,int>::iterator it;

ll to(ll x)
{
	for(ll i=2;;i++)
	{
		ll t=i*i*i;
		if(t>x) break;
		while(x%t==0) x/=t;
	}
	return x;
}
ll tg(ll x)//toしてる -> x=P*Q^2 に直したい -> そして、P^2*Qに
{
	ll A=1,B=1;
	for(ll i=2;;i++)
	{
		if(i*i*i>x) break;
		int cnt=0;
		while(x%i==0)
		{
			x/=i;
			cnt++;
		}
		if(cnt%2==1)
		{
			A*=i;
			cnt--;
		}
		for(int j=0;j<cnt/2;j++) B*=i;
	}
	//x/(A*B^2)=C*D^2だから、C=1 or D=1
	ll dt=(ll) floor(sqrt(x)+0.5);
	if(dt*dt==x) B*=dt;
	else A*=x;
	return A*A*B;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		ll x;
		scanf("%lld",&x);
		x=to(x);
		//printf("%lld ",x);
		mp[x]++;
	}
	//puts("");
	int ret=0;
	for(it=mp.begin();it!=mp.end();it++)
	{
		ll x=it->first;
		int cnt=it->second;
		ll t=tg(x);
		//if(x<=t) printf("%lld %lld : %d %d\n",x,t,mp[x],mp[t]);
		if(x<t) ret+=max(cnt,mp[t]);
		else if(x==t) ret++;
	}
	printf("%d\n",ret);
	return 0;
}

Submission Info

Submission Time
Task D - Anticube
User yutaka1999
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1201 Byte
Status WA
Exec Time 5254 ms
Memory 11264 KB

Compile Error

./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);
                ^
./Main.cpp:57:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 23
WA × 6
TLE × 22
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 5254 ms 11136 KB
02.txt TLE 5254 ms 11136 KB
03.txt TLE 5254 ms 11136 KB
04.txt TLE 5254 ms 11136 KB
05.txt TLE 5254 ms 11264 KB
06.txt TLE 5254 ms 11136 KB
07.txt TLE 5254 ms 11264 KB
08.txt TLE 5254 ms 11264 KB
09.txt TLE 5254 ms 11136 KB
10.txt TLE 5254 ms 11264 KB
11.txt TLE 5253 ms 3456 KB
12.txt TLE 5253 ms 3456 KB
13.txt WA 2255 ms 3968 KB
14.txt WA 2253 ms 3968 KB
15.txt WA 2250 ms 4096 KB
16.txt WA 2270 ms 3968 KB
17.txt AC 62 ms 256 KB
18.txt AC 62 ms 256 KB
19.txt AC 62 ms 256 KB
20.txt AC 62 ms 256 KB
21.txt TLE 5254 ms 6784 KB
22.txt TLE 5254 ms 6784 KB
23.txt TLE 5254 ms 6784 KB
24.txt TLE 5254 ms 6784 KB
25.txt TLE 5254 ms 6784 KB
26.txt TLE 5254 ms 6784 KB
27.txt AC 700 ms 10496 KB
28.txt AC 16 ms 256 KB
29.txt AC 22 ms 256 KB
30.txt WA 18 ms 256 KB
31.txt AC 19 ms 256 KB
32.txt AC 19 ms 256 KB
33.txt AC 13 ms 256 KB
34.txt AC 54 ms 256 KB
35.txt AC 53 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt TLE 5253 ms 4224 KB
38.txt TLE 5253 ms 4224 KB
39.txt TLE 5253 ms 4224 KB
40.txt TLE 5254 ms 4352 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 40 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 WA 4 ms 256 KB
48.txt AC 3 ms 256 KB
s1.txt AC 3 ms 256 KB
s2.txt AC 3 ms 256 KB
s3.txt AC 40 ms 256 KB