-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCUBEFR.cpp
More file actions
47 lines (47 loc) · 754 Bytes
/
CUBEFR.cpp
File metadata and controls
47 lines (47 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
#include<iostream>
using namespace std;
#define gc getchar_unlocked
inline void scanint(int &x)
{
register int c = gc();
x = 0;
int neg = 0;
for(;((c<48 || c>57) && c != '-');c = gc());
if(c=='-') {neg=1;c=gc();}
for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
if(neg) x=-x;
}
int A[1000001]={0};
void cube_free()
{
int i,k,j;
for(i=2;i<=100;i++)
{
if(A[i]==0)
{
k=i*i*i;
for(j=k;j<=1000000;j+=k)
A[j]=-1;
}
}
k=1;
for(i=1;i<=1000000;i++)
if(A[i]==0)
A[i]=k++;
}
int main()
{
cube_free();
int t,n;
scanint(t);
for(int i=1;i<=t;i++)
{
scanint(n);
if(A[n] != -1)
printf("Case %d: %d\n",n,A[n] );
else
printf("Case %d: Not Cube Free\n",n);
}
return 0;
}