You are viewing a single comment's thread. Return to all comments →
in c
bool check_abundant(int n) {
int sum = 1; for (int i = 2; i * i <= n; ++i) { if (n % i == 0) { sum += i; if (i != n / i) { sum += n / i; } } } return sum > n;
}
bool two_abundant_number(int n) {
for (int i = 12; i <= n / 2; ++i) { if (check_abundant(i) && check_abundant(n - i)) { return true; } } return false;
int main() {
int t; scanf("%d", &t); char results[t][4]; for (int i = 0; i < t; ++i) { int n; scanf("%d", &n); if (two_abundant_number(n)) { sprintf(results[i], "YES"); } else { sprintf(results[i], "NO"); } } for (int i = 0; i < t; ++i) { printf("%s\n", results[i]); } return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #23: Non-abundant sums
You are viewing a single comment's thread. Return to all comments →
in c
include
include
include
include
include
include
include
include
include
include
bool check_abundant(int n) {
}
bool two_abundant_number(int n) {
}
int main() {
}