## 문제
BOJ 3052 나머지
## 풀이
수 10개를 입력받아서 서로 다른 나머지의 숫자 개수를 구하는것. set을 이욯해서 풀어도 되고 새로 배열을 만들어서 없는값만 담아도 좋을 것 같다.
## 코드
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
lines = sys.stdin.readlines() | |
tmp_list = [] | |
for line in lines: | |
tmp_list += [int(line[:-1])%42] | |
print(len(set(tmp_list))) |
하나씩 input 받을수도 있겠지만 readlines() 을 이용해서 한번에 받은 후에 해결해보자. 개행문자가 붙으므로 [:-1] 붙여서 int로 바꾸어야 한다.
0 댓글