Programming/Python & Data Structures
[Baekjoon/Python3] 4641번 Doubles
HooNeee
2020. 12. 4. 17:36
[Baekjoon/Python3] 4641번 Doubles
4641번: Doubles
2~15개의 서로 다른 자연수로 이루어진 리스트가 있을 때, 이들 중 리스트 안에 자신의 정확히 2배인 수가 있는 수의 개수를 구하여라. 예를 들어, 리스트가 "1 4 3 2 9 7 18 22"라면 2가 1의 2배, 4가 2의
www.acmicpc.net
while True:
cnt = 0
nums = list(map(int, input().split()))
if -1 in nums:
break
for n in nums[:-1]:
if n * 2 in nums:
cnt += 1
print(cnt)