-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2757.cpp
73 lines (63 loc) · 1.02 KB
/
2757.cpp
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 <math.h>
using namespace std;
int arr[1500];
int isprime(int n);
void createdata(void);
int main()
{
long long n;
int m=1;
cin>>n;
createdata();
arr[0]=2;
/*for(int i=0;i<200;i++)
{
cout<<i<<"\t"<<arr[i]<<endl;;
}
cout<<endl;*/
//cout<<"start"<<endl;
int counter=0;
while(n!=1)
{
//cout<<counter<<endl;
if(n%arr[counter]==0)
{
m*=arr[counter];
while(n%arr[counter]==0)
{
n/=arr[counter];
}
}
counter++;
if(counter>1499)
{
m=n;
break;
}
}
cout<<m<<endl;
return 0;
}
void createdata(void)
{
int counter=1;
long long num=2;
while(counter<1500)
{
if(isprime(num))
{
arr[counter]=num;
counter++;
}
num++;
}
}
int isprime(int n)
{
for(int i=2;i<sqrt(n)+1;i++)
{
if(n%i==0) return 0;
}
return 1;
}