三等分数组
输入数组长度和具体数值,使其三等分,不存在平分方案输出0
# n=int(input()) m=list(map(int,input().split())) sum1=sum(m) def t(a,b,c,l,s): if len(l)==0: if sum(a)==sum(b)==sum(c): global f f=[] f.append(a) f.append(b) f.append(c) return True else: return False if (sum(a)<=s and t(a+[l[0]],b,c,l[1:],s))&nbs***bsp;(sum(b)<=s and t(a,b+[l[0]],c,l[1:],s))&nbs***bsp;(sum(c)<=s and t(a,b,c+[l[0]],l[1:],s)): return True else: return False a=[] b=[] c=[] if (sum1%3)!=0: print(0) else: if t(a,b,c,m,sum1//3): print(f) else: print(0)