std::vector<int> abundantnums(std::vector<bool>& allnumbers){ std::vector<int> result; for(unsigned int i = 1; i < 28124; i++){ allnumbers.push_back(false); if(abundant(i)) result.push_back(i); } return result; }
int main(int argc, char **argv) { int i, *temp; int *array; int counter = 0; temp = malloc(1); array = malloc(atoi(argv[1])); for (i = 0; i < atoi(argv[1]); i++) { *temp = i; if (abundant(temp)) { printf("%d\n", i); array[counter++] = i; } } return 0; }
int main(void) { std::vector<int> abundants; for(int i = 2; i <= LIMIT ; i++) { if(abundant(i)) abundants.push_back(i); } bool sums[28123] = {false}; for(int i = 0; i < abundants.size(); i++) { for(int j = i; j < abundants.size(); j++) { if(abundants[i] + abundants[j] <= LIMIT) sums[abundants[i] + abundants[j]] = true; else break; } } int ans = 0; for(int i = 1; i <= LIMIT; i++) { if (!sums[i]) ans += i; } std::cout << ans << std::endl; return 0; }
int main() { int abund[MAX]; int twoabund[MAX]; int i, j; int sum = 0; for (i = 0; i < MAX; i++) abund[i] = abundant(i); memset(twoabund, 0, MAX * sizeof(int)); for (int i = 0; i < MAX; i++) { if (!abund[i]) continue; for (int j = 0; j < MAX; j++) { if (!abund[j]) continue; if (i + j < MAX) twoabund[i + j] = 1; } } for (i = 0; i < MAX; i++) if (!twoabund[i]) sum += i; printf("%d\n", sum); return 0; }