|
|
back to boardHelp ! Why Wrong Answers? What could be the problem? My assumption is when N <= k the answer is N*N. The rest is normal calculation. But I always got WRONG ANSWER !!! Please help !!! *************************** #include <stdio.h> #include <stdlib.h> void main () { int number, number_of_factoral; int total, i, frequency; char factor[21]; div_t result; int option;
scanf("%d %s",&number, factor); number_of_factoral = strlen(factor); if (number <= number_of_factoral) { total = number * number; } else { result = div(number, number_of_factoral); total = number; i = 1;
while ((number - (i * number_of_factoral)) > 0) { total = total * (number- (i * number_of_factoral)); i = i + 1; }
if (result.rem > 0) total = total * result.rem; else total = total * number_of_factoral; } printf("%d\n", total); } ****************************** |
|
|