#include <iostream>
#include <cmath>
#include <vector>
using ull = unsigned long long;
ull sito(ull f) {
ull k = 1;
std::vector<ull> prime;
bool isP;
ull fx = std::sqrt(f);
for (ull i = 2; i <= fx; i++) {
if (f % i == 0) {
isP = true;
for (int j = 0; j != prime.size(); j++) {
if (i % prime[j] == 0) {
isP = false;
break;
}
}
if (isP) {
prime.push_back(i);
k = i;
}
}
}
return k;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie();
int n;
ull f = 0, a, k;
std::cin >> n;
for (int i = 0; i < n; i++) {
std::cin >> a;
f += a;
}
k = sito(f);
std::cout << k;
return 0;
}
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 | #include <iostream> #include <cmath> #include <vector> using ull = unsigned long long; ull sito(ull f) { ull k = 1; std::vector<ull> prime; bool isP; ull fx = std::sqrt(f); for (ull i = 2; i <= fx; i++) { if (f % i == 0) { isP = true; for (int j = 0; j != prime.size(); j++) { if (i % prime[j] == 0) { isP = false; break; } } if (isP) { prime.push_back(i); k = i; } } } return k; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(); int n; ull f = 0, a, k; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> a; f += a; } k = sito(f); std::cout << k; return 0; } |
English