You are viewing a single comment's thread. Return to all comments →
def check(n,x): s = '' for i in range(n): t = str(x[i]) s += t s = str(s) p = list(permutations(s)) for q in p: digit = int(''.join(q)) if digit%3 ==0: return True else: return False from itertools import permutations for _ in range(int(input())): n = int(input()) x = list(map(int, input().split())) print('Yes' if check(n,x) else 'No')
Seems like cookies are disabled on this browser, please enable them to open this website
Constructing a Number
You are viewing a single comment's thread. Return to all comments →