python代码答案正确,2个WA,7个TLE和1个AC,希望大佬帮忙
查看原帖
python代码答案正确,2个WA,7个TLE和1个AC,希望大佬帮忙
945560
zaizaibao114514ZAU楼主2023/4/11 22:06

import random

N, M, K = map(int, input().split())

cnt = 0 T = 1000000 # 统计次数

for i in range(T): p = list(range(1, N+1)) random.shuffle(p) L = sum(abs(p[i]-p[i-1]) for i in range(1, N)) if L >= M: cnt += 1

res = cnt / T print('%.{}f'.format(K) % res)

2023/4/11 22:06
加载中...