[백준] 2089번 (python 파이썬)
https://www.acmicpc.net/problem/2089 2089번: -2진수 -2진법은 부호 없는 2진수로 표현이 된다. 2진법에서는 20, 21, 22, 23이 표현 되지만 -2진법에서는 (-2)0 = 1, (-2)1 = -2, (-2)2 = 4, (-2)3 = -8을 표현한다. 10진수로 1부터 표현하자면 1, 110, 111, 100, 101, 11010, 110 www.acmicpc.net number = int(input()) if number == 0 : print(0) else: d = number result = "" while d != 1: r = d % -2 d = d // -2 if r < 0: d += 1 r *= (-1) result += str(r) else: resu..
[백준] 2004번 (python 파이썬)
https://www.acmicpc.net/problem/2004 2004번: 조합 0의 개수 첫째 줄에 정수 $n$, $m$ ($0 \le m \le n \le 2,000,000,000$, $n \ne 0$)이 들어온다. www.acmicpc.net n, m = map(int, input().split()) def get_count(n, k): count = 0 while n: n = n // k count += n return count result = min(get_count(n, 2) - get_count(n-m, 2) - get_count(m, 2),\ get_count(n, 5) - get_count(n-m, 5) - get_count(m, 5)) print(result) n! 에서 끝자리 0..