Create 1144_***117.cpp

This commit is contained in:
KiritoTRw 2016-05-01 18:47:16 +08:00
parent 2fc9b9bc2a
commit 1ad75c6184

41
QUSTOJ/1144_***117.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <cstdio>
#include <cmath>
int prime[20010],f[20000];
void prime_2()
{
int n=20000,t=0;
for (int i=2;i<=n;i++)
{
if (!f[i])
{
prime[t++]=i;
int j=2*i;
while (j<=n)
{
f[j]=1;
j+=i;
}
}
}
}
int main ()
{
int n,x;
prime_2();
scanf("%d",&n);
int max=-1,m=0;
for (int i=0;i<n;i++)
{
scanf("%d",&x);
if (n==1) m=x;
else
for (int j=0;prime[j]<=x;j++)
if (x%prime[j]==0&&j>max)
{
max=j;
m=x;
}
}
printf("%d",m);
return 0;
}