접근 방법
- N의 약수를 구해서 리스트로 만들었다.
- 리스트를 앞과 뒤를 짝지어서 비교했다.
- 예를 들어 6의 약수이면 [1, 2, 3, 6]인데
- 차례차례 1과 6, 2와 3을 비교했다.(즉 둘이 곱해서 N이 되는 약수들)
- 그리고 약수의 숫자가 둘다 9 이하이면 끝!
코드
TC = int(input())
for t in range(1,TC+1):
N = int(input())
lst = []
for n in range(1, N+1):
if N % n == 0:
lst.append(n)
res = 'No'
idx = 0
if len(lst) % 2:
while idx < len(lst)//2 + 1:
if lst[idx] <= 9 and lst[len(lst)-1-idx] <= 9:
res = 'Yes'
break
idx += 1
else:
while idx < len(lst)//2:
if lst[idx] <= 9 and lst[len(lst)-1-idx] <= 9:
res = 'Yes'
break
idx += 1
print('#{} {}'.format(t, res))