We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[백준] 2064번 IP 주소
### 풀이 언어 - python/java ### 코드 ```python/java ``` ### 핵심 로직 혹은 자료구조 - ### 시간 복잡도 - O( )
The text was updated successfully, but these errors were encountered:
import sys input = sys.stdin.readline n = int(input()) ipAddress = [] for _ in range(n): address = list(map(int, input().split("."))) tmp = '' for a in address: t = format(a, 'b') tmp += '0'*(8-len(t)) + t ipAddress.append(tmp) ipAddress.sort() ip, mask = '', '' for i in range(32): if int(ipAddress[0][i]) ^ int(ipAddress[-1][i]) == 1: break else: ip += ipAddress[0][i] mask += '1' ip += '0'*(32-i) mask += '0'*(32-i) ans1, ans2, tmp1, tmp2 = ['' for _ in range(4)] for i in range(32): tmp1 += ip[i] tmp2 += mask[i] if (i+1)%8 == 0: ans1 += str(int(tmp1, 2)) + '.' ans2 += str(int(tmp2, 2)) + '.' tmp1, tmp2 = '', '' print(ans1[:-1]) print(ans2[:-1])
Sorry, something went wrong.
nathan29849
No branches or pull requests
TITLE
[백준] 2064번 IP 주소
LINK
📷 Screenshots
댓글 양식
The text was updated successfully, but these errors were encountered: