第一行输入整数
,表示测试用例数量。
随后
行,每行一个数字串
,长度
,保证所有用例数字串
的总长度
。
对每个用例输出 ``
`` 或 ``
``(大写),表示是否存在操作序列使得最终数字能被
整除。
9 123 322 333333333333 9997 5472778912773 1234567890 23 33 52254522632
NO YES YES NO NO YES NO YES YES
在第一组样例中,从整数中只能得到
、
、
和
,它们都不能被
整除。
在第二组样例中,需要将第二个数字替换为它的平方,那么就等于
。
在第三组样例中,整数已经可以被整除。
t = int(input()) def solve(): s =list(map(int, input())) total = sum(s) f = total # print(total) if total%9==0: print("YES") return h = { 2:0, 3:0 } for i in s: if i==2: h[2]=h[2]+1 elif i==3: h[3]=h[3]+1 # print(h) for i in range(h[2]+1): for j in range(h[3]+1): total = total + i*2 + j*6 # print(total) if total%9==0: print("YES") return else: total = f print("NO") for _ in range(t): solve() # 呃呃