Timus 1083. Factorials!!! Accepted Solution in C
#include <stdio.h>
int main()
{
int i, n, k, sum;
char input[24];
gets(input);
if(input[1] == ' ') {
n = input[0] - '0';
i = 2;
} else {
n = 10;
i = 3;
}
k = i;
while(input[i]) i++;
k = i - k;
sum = 1;
for(i = n; i > 0; i -= k) sum *= i;
printf("%d", sum);
return 0;
}
int main()
{
int i, n, k, sum;
char input[24];
gets(input);
if(input[1] == ' ') {
n = input[0] - '0';
i = 2;
} else {
n = 10;
i = 3;
}
k = i;
while(input[i]) i++;
k = i - k;
sum = 1;
for(i = n; i > 0; i -= k) sum *= i;
printf("%d", sum);
return 0;
}
Comments
Post a Comment