#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int factorial(int n)
{
if (n < 1)
return 1;
else
return n*factorial(n - 1);
}
int main(void)
{
int n, k, sum = 0, i, res;
scanf("%d %d", &n, &k);
for (i = 0; i <= n; i++)
{
sum += pow((double)factorial(i), k);
}
while (1)
{
res = sum % 10;
if (res != 0)
break;
}
printf("%d", res);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '4' |
2 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '2' |
3 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '2' |
4 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '2' |
5 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '2' |
6 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '4' |
7 |
Correct |
0 ms |
1280 KB |
Output is correct - answer is '6' |
8 |
Execution timed out |
1000 ms |
1276 KB |
Program timed out |
9 |
Halted |
0 ms |
0 KB |
- |