본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#281 백준 파이썬 [16680] 안수빈수

https://www.acmicpc.net/problem/16680

 

SOLUTION

N의 배수의 자릿수를 합해서 짝수를 출력하면 되는 문제다.

시간 초과에 유의하며 풀어준다.

PYTHON CODE

T = int(input())

for _ in range(T):
    N = int(input())
    
    while N <=1000000000000000000:
        sum_digit = 0 #자릿수의 합
        temp = N
        
        #자릿수를 구하는 함수
        while temp != 0: 
            sum_digit += temp % 10
            temp = temp // 10

        if sum_digit % 2 == 1:
            print(N)
            break
            
        else:
            N += N #다음 배수