int main(int argc, char *argv[]) { // Benchmark variables double start, end; // Helper variables unsigned int abundants[MAX] = {0}, results[MAX] = {0}, total = 0; // Starting the core algorithm printf("Algorithm starts, please wait...\n"); start = clock(); // Iterating trough numbers for(unsigned int i = 1; i < MAX; i++) { if(summatory(i) > i) // Actually this is the main checking point for abundant number { abundants[i] = 1; // Flag the position i as abundant } } // Repeat the iteration for(unsigned int i = 1; i < MAX; i++) { // But now 2D version of this iteration... for(unsigned int j = 1; j < MAX; j++) { // ...because we need to check even the sum of two numbers if(abundants[i] == 1 && abundants[j] == 1 && (( i + j) < MAX)) { results[i+j] = 1; // Flag the position } } } // Repeat the iteration for(unsigned int i = 1; i < MAX; i++) { // Check for a flag if(results[i] == 0) total += i; // sum the position to the total } // Core end end = clock(); printf("%d\n", total); printf("Algorithm end.\n"); printf("Total time: %f\n", (end - start)/CLOCKS_PER_SEC); return 0; }
void gen_power() { ll k,m,x; for(m=0;m<=325;m++) { ll s = inv2[m+1]; for(k=0;k<=m;k++) { if(!B[k]) { f[m][m+1-k] += 0; continue; } x = ((((fact[m+1] * inv[m+1-k])%mod) * inv[k])%mod * B[k])%mod; x = (x*s)%mod; summatory(m+1-k,m,x); } } }