#include <stdio.h> #include <stdlib.h> //#include <time.h> #include <math.h> int main(int argc, char *argv[]) { int sum = 0; int i, j, k; int number_counter = 0; scanf("%d",&sum); //clock_t tStart = clock(); int firstformax = ceil(sqrt(sum-1)); int secondsum; int secondformax; for(i = 1; i <= firstformax; i++){ if((sum-i)%i == 0){ secondsum = sum/i-1; secondformax = floor(sqrt(secondsum)); for(j = 2; j <= secondformax; j++){ if((secondsum-j)%(j) == 0 ){ number_counter++; if(i*(secondsum/j) < (sum-i-i*(secondsum/j)) && j < secondsum/j) number_counter++; } } if(sum/i <= sum/7 && i != sum/i){ secondsum = sum/(sum/i)-1; secondformax = floor(sqrt(secondsum)); for(j = 2; j <= secondformax; j++){ if((secondsum-j)%(j) == 0 ){ number_counter++; if(sum/i*(secondsum/j) < (sum-(sum/i)-(sum/i)*(secondsum/j)) && j < secondsum/j) number_counter++; } } } } } //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); printf("%d", number_counter); 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 | #include <stdio.h> #include <stdlib.h> //#include <time.h> #include <math.h> int main(int argc, char *argv[]) { int sum = 0; int i, j, k; int number_counter = 0; scanf("%d",&sum); //clock_t tStart = clock(); int firstformax = ceil(sqrt(sum-1)); int secondsum; int secondformax; for(i = 1; i <= firstformax; i++){ if((sum-i)%i == 0){ secondsum = sum/i-1; secondformax = floor(sqrt(secondsum)); for(j = 2; j <= secondformax; j++){ if((secondsum-j)%(j) == 0 ){ number_counter++; if(i*(secondsum/j) < (sum-i-i*(secondsum/j)) && j < secondsum/j) number_counter++; } } if(sum/i <= sum/7 && i != sum/i){ secondsum = sum/(sum/i)-1; secondformax = floor(sqrt(secondsum)); for(j = 2; j <= secondformax; j++){ if((secondsum-j)%(j) == 0 ){ number_counter++; if(sum/i*(secondsum/j) < (sum-(sum/i)-(sum/i)*(secondsum/j)) && j < secondsum/j) number_counter++; } } } } } //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); printf("%d", number_counter); return 0; } |