728x90
반응형
문제 출처:https://www.acmicpc.net/problem/10871
10871번: X보다 작은 수
첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다.
www.acmicpc.net
풀이:
input = sys.stdin.readline
a,b = map(int,(input().split())) #입력받은 N,X map함수 사용해서 int로 변환
c = list(map(int,input().split())) #입력받은 수열 A 리스트로 받음
print(c)
result = ''
for i in c:
if i<b: # 리스트 c에 있는거 하나씩 빼와서 b 보다 작을때
#print(type(i)) # i에 type은 int
#print(type(result)) # result 에 type 은 str
result +=str(i)+ ' ' # type 이 맞춰주기위해 str(i)를 써줌
print(result)
Python Type 확인
https://codechacha.com/ko/python-type-check/
Python - 데이터 Type 확인 - type(), isinstance()
파이썬에서 객체의 타입을 확인할 때 다음 함수를 사용할 수 있습니다. type(variable)는 인자로 전달된 객체의 타입을 리턴합니다. isinstance(variable, type) 인자로 전달된 객체가 type과 일치하는지, 또
codechacha.com
반응형
댓글