123123
123
有空写写自己为数不多的会写的题
import itertools
a = int(input())
num = list(itertools.permutations([i for i in range(1,a+1)]))
ans = []
for m in range(len(num)):
flog = 0
for shu1 in num[m]:
#print(shu1)
for shu2 in num[m][:num[m].index(shu1)]:
if shu1>shu2:
flog+=1
ans.append(flog)
print(sum(ans))
我的水平只能写成这样了,但是试了下,样例超过10就会超时,还是数学不行。