-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.cpp
More file actions
61 lines (42 loc) · 804 Bytes
/
3.cpp
File metadata and controls
61 lines (42 loc) · 804 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
#include<iostream>
#include<math.h>
using namespace std;
bool isPrime(long long int a)
{
long long int last=sqrt(a);
for(long long int i=2;i<=last;i++)
{
if(a%i==0)
return false;
}
return true;
}
int main()
{
long long int t,n,i,j,last,large=1;
cin>>t;
while(t--)
{
cin>>n;
last=sqrt(n);
for(i=1;i<=last;i++)
{
if(n%i==0)
{
if(isPrime(i))
{
if(large<i)
large=i;
}
if(isPrime(n/i))
{
large=n/i;
break;
}
}
}
cout<<large<<endl;
large=1;
}
return 0;
}