| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
注意1的情况,顺便粘一发代码#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 20005;
int n, ans = 1, prime = 1;
int pre[N], pri[N], tot = 0;
signed main(void) {
memset(pre, 0, sizeof(pre));
for (int i = 2; i < N; i++) {
if (pre[i] == 0)pri[++tot] = i;
for (int j = 1; j <= tot&&i*pri[j] < N; j++) {
pre[i*pri[j]] = pri[j];
if (i%pri[j] == 0)break;
}
}
scanf_s("%d", &n);
for (int i = 1, x; i <= n; i++) {
scanf_s("%d", &x);
for(int j=lower_bound(pri+1,pri+1+tot,x)-pri;j;j--)
if (pri[j] <= x&&x%pri[j] == 0) {
if (prime < pri[j])prime = pri[j], ans = x;
break;
}
}
printf("%d\n", ans);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator