Skip to content

Commit 43c75c8

Browse files
committed
[BOJ]#1629.곱셈/Silver1/실패
https://www.acmicpc.net/problem/1629
1 parent f1f6e95 commit 43c75c8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Hongjoo/백준/곱셈.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sys
2+
a,b,c = map(int,sys.stdin.readline().split())
3+
4+
def multi (a,n):
5+
if n == 1:
6+
return a%c
7+
else:
8+
tmp = multi(a,n//2)
9+
if n %2 ==0:
10+
return (tmp * tmp) % c
11+
else:
12+
return (tmp * tmp *a) %c
13+
14+
print(multi(a,b))

0 commit comments

Comments
 (0)