image

python:

s0=int(input())
for _ in range(s0):
    nothing=int(input())
    arr=[int(x) for x in input().split()]
    three=arr.count(3)
    six=arr.count(6)
    nine=arr.count(9)
    zero=arr.count(0)
    v=0
    if(sum(arr)%9==6):
        if(six>0):
            arr.remove(6)
        elif(arr.count(3)>=2):
            arr.remove(3)
            arr.remove(3)
        else:
            v=1
    if(sum(arr)%9==3):
        if(three>0):
            arr.remove(3)
        elif(six>=2):
            arr.remove(6)
            arr.remove(6)
        else:
            v=1
    if(three ==0 and six  ==0 and nine ==0):
        if zero>0:
            print('0')
        else:
            print('-1')
    elif(len(arr)>0):
        print(*sorted(arr,reverse=True),sep=' ')
    else:
        print('-1')
arrow
arrow
    文章標籤
    python 台東大學考題
    全站熱搜
    創作者介紹
    創作者 趴趴熊日常 的頭像
    趴趴熊日常

    資工趴趴熊的小天地

    趴趴熊日常 發表在 痞客邦 留言(1) 人氣()