-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path2345.cpp
More file actions
47 lines (40 loc) · 960 Bytes
/
2345.cpp
File metadata and controls
47 lines (40 loc) · 960 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<bits/stdc++.h>
using namespace std;
int SieveOfEratosthenes(int n)
{
// Create a boolean array "prime[0..n]" and initialize
// all entries it as true. A value in prime[i] will
// finally be false if i is Not a prime, else true.
bool prime[n+1];
memset(prime, true, sizeof(prime));
for (int p=2; p*p<=n; p++)
{
if (prime[p] == true)
{
for (int i=p*p; i<=n; i += p)
prime[i] = false;
}
}
int ctr=0;
for (int p=2; p<=n; p++)
{ if (prime[p])
ctr++;}
return ctr;
}
int main()
{
int t;
cin>>t;
while(t--)
{ int n;cin>>n;
int ctr=SieveOfEratosthenes(n);
// cout<<ctr<<endl;
if(ctr==0)
cout<<"Harshit"<<endl;
else if(ctr%2!=0)
cout<<"Aahad"<<endl;
else
cout<<"Harshit"<<endl;
}
return 0;
}