Programming/Python & Data Structures
[Baekjoon/Python3] 8741번 이진수 합
HooNeee
2020. 12. 5. 22:04
[Baekjoon/Python3] 8741번 이진수 합
8741번: 이진수 합
첫째 줄에 이진수로 나타냈을 때, k자리 이하인 모든 자연수의 합을 이진수로 출력한다.
www.acmicpc.net
import sys
k = 2 ** int(sys.stdin.readline()) - 1
print(bin((1 + k) * k // 2)[2:])