def main():
n,k=list(map(int,input().split()))
S=0
fact=[1,1,2,6,24,120,720,5040,40320,362880]
for i in range(0,min(n,9)+1):
S+=fact[i]**k
print(S%10) if S%10 else print((S//10)%10)
main()
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
3 KB |
answer is '4' |
2 |
Correct |
28 ms |
3 KB |
answer is '2' |
3 |
Correct |
28 ms |
3 KB |
answer is '2' |
4 |
Correct |
22 ms |
3 KB |
answer is '2' |
5 |
Correct |
28 ms |
3 KB |
answer is '2' |
6 |
Correct |
34 ms |
3 KB |
answer is '4' |
7 |
Correct |
22 ms |
3 KB |
answer is '6' |
8 |
Correct |
28 ms |
3 KB |
answer is '1' |
9 |
Correct |
26 ms |
3 KB |
answer is '2' |
10 |
Correct |
27 ms |
3 KB |
answer is '6' |
11 |
Correct |
30 ms |
3 KB |
answer is '4' |
12 |
Correct |
37 ms |
3 KB |
answer is '5' |
13 |
Correct |
28 ms |
3 KB |
answer is '2' |
14 |
Correct |
29 ms |
3 KB |
answer is '3' |
15 |
Correct |
30 ms |
3 KB |
answer is '4' |
16 |
Correct |
32 ms |
3 KB |
answer is '5' |
17 |
Correct |
29 ms |
3 KB |
answer is '6' |
18 |
Correct |
29 ms |
3 KB |
answer is '7' |
19 |
Correct |
27 ms |
3 KB |
answer is '8' |
20 |
Correct |
26 ms |
3 KB |
answer is '9' |
21 |
Correct |
28 ms |
3 KB |
answer is '1' |
22 |
Correct |
38 ms |
3 KB |
answer is '6' |
23 |
Incorrect |
29 ms |
3 KB |
expected '3', found '1' |
24 |
Halted |
0 ms |
0 KB |
- |