백준 33756번: 88888 #Python

ColorlessDia·2025년 5월 23일

algorithm/baekjoon

목록 보기
551/807
import sys

input = sys.stdin.readline

eight_number_list = [int('8' * i) for i in range(18, 0, -1)]

T = int(input())

for _ in range(T):
    N = int(input())

    count = 0

    for eight_number in eight_number_list:
        
        if N < eight_number:
            continue
        
        while eight_number <= N:
            N -= eight_number
            count += 1

    result = 'Yes' if N == 0 and count <= 8 else 'No'

    print(result)

0개의 댓글