-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPSYCHON_TEST.cpp
More file actions
74 lines (68 loc) · 1004 Bytes
/
PSYCHON_TEST.cpp
File metadata and controls
74 lines (68 loc) · 1004 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int *psy=new int[10000001];
bool *p=new bool[10000001];
for (int i = 0; i <= 10000000; i++)
{
psy[i]=0;
if(i<3163)
p[i]=true;
}
psy[1]=0;
for (int i = 2; i < 10000001; i++)
{
if(p[i])
{
for (int j = i+i; j < 10000001 ; j+=i)
{
p[j]=false;
}
}
}
for (int i = 2; i < 3163; i++)
{
if(p[i])
{
//cout<<i<<endl;
bool t=false;
for (long long k=i,m=1; k<=10000000 ;t^=1,m++)
{
int sum;
if(m==1)
sum=1;
else
sum=2;
for (int j = k; j <= 10000000 ; j+=k)
{
if(t)
psy[j]+=sum;
else
psy[j]-=sum;
}
k*=i;
}
}
}
int t,no;
cin>>t;
while(t--)
{
scanf("%d",&no);
//cout<<psy[no];
if(psy[no]>0)
printf("Psycho Number\n");
else
printf("Ordinary Number\n");
}
/*for (int i = 0; i < 10000; i++)
{
if(psy[i]>0)
cout<<i<<":"<<psy[i]<<"\n";
}*/
delete []p;
delete []psy;
}