解答错误
输入:[, , , , , , , , , ]
输出:7
预期结果:5 旅途Z 发表于 2020-4-9 13:17
解答错误
输入:[, , , , , , , , , , , , , , , , , , , , , , , , ]
输出:13
预期结果:12 阴阳神万物主 发表于 2020-4-9 17:02
难度评级:简单
要素分析:数论
随机输入生成器,送给有需要的人:
解答错误
输入:[, , , , ]
输出:6
预期结果:4 chen971130 发表于 2020-4-9 20:17
解答错误
输入:[, , , , , , , , , ]
输出:7
预期结果:5 钙硼钡锗 发表于 2020-4-10 09:11
解答错误
输入:[, , , , , , , , , ]
输出:7
预期结果:5 whosyourdaddy 发表于 2020-4-8 23:14
发代码应该这样发:https://fishc.com.cn/forum.php?mod=viewthread&tid=52272&extra=page%3D1%26filter%3Dtypeid%26typeid%3D441 def func371(intervals):
count = 0
newlist = sorted(intervals,key = lambda s:s)
result = [(newlist-1),newlist]
for i in range(1,len(newlist)):
for j in result:
if j <=newlist and j>=newlist:
count += 1
temp = j
if count == 2:
break
if count == 0:
result.append((newlist-1))
result.append(newlist)
if count == 1:
if temp !=newlist:
result.append(newlist)
else:
result.append(newlist-1)
count = 0
return len(result) zltzlt 发表于 2020-4-10 13:15
解答错误
输入:[, , , , ]
修好了
def solve(intervals:list,how:'是否打印最小集合'=False):
sets = ,i+1))for i in intervals]
setses = sets[:]
u = set()
while sets:
n = []
l = len(sets)
flg = *l
for a in range(l-1):
for b in range(a+1,l):
c = sets.intersection(sets)
if len(c)>=2:
if c not in n:n.append(c)
flg,flg = False,False
if flg:n.append(sets)
if flg[-1]:n.append(sets[-1])
if n == sets:break
sets = n
db = [for i in setses]
def rm(a,s):
i = 0
while i<len(a):
if s in a:
a.pop(i)
else:
i+= 1
while db:
for each in db:
if len(each)==1:
u.update({each.pop(),each.pop()})
rm(db,each)
break
else:
nd = []
for each in sets:
n = 0
for l in db:
if each in l:n += 1
nd.append((each,n))
nd.sort(key=lambda x:x,reverse=True)
u.update({nd.pop(),nd.pop()})
rm(db,nd)
if how:print(intervals,'->',u)
return len(u)
if __name__ == '__main__':
print('示例1 输出:',solve([, , , ],1))
print('示例2 输出:',solve([, , , ]))
print('之前错的:',solve([, , , , ],1)) from itertools import combinations
def fun371(intervals):
intervals = [,i+1)] for i in intervals]
total = for j in intervals),max(j for j in intervals)+1)]
for i in range(2,len(total)+1):
for j in combinations(total,i):
for n in intervals:
count = 0
for m in j:
if m in n:
count += 1
if count < 2:
break
else:
return len(j)
页:
1
[2]