BOJ - 10448 - 유레카 이론

Updated:

import sys

def solution():
    N = int(input())
    arr = []
    for _ in range(N):
        arr.append(int(sys.stdin.readline()))

    first = []
    second = []
    third = []
    idx = 1
    while True:
        yureakNumber = (idx + 1) * idx // 2
        if yureakNumber > max(arr): break
        else:
            first.append(yureakNumber)
            idx += 1

    for i in range(len(first)):
        for j in range(i, len(first)):
            if first[i] + first[j] <= max(arr):
                second.append(first[i] + first[j])

    for i in first:
        for j in second:
            if i + j <= max(arr):
                third.append(i + j)

    for i in arr:
        if i in third: print(1)
        else: print(0)

solution()

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

Categories:

Updated:

Leave a comment