阿里巴巴9.17超时代码
# 60 % 超时 t = int(input()) for _ in range(t): n, k = map(int, input().split()) ans = 0 for i in range(k, n+1): for j in range(k+1, n+1): if i % j == k: ans += 1 print(ans) # 58.33 % 超时 n, k = map(int, input().split()) nums = list(map(int, input().split())) ans = 0 if k >= 1: ans += n if k >= 2: for i in range(n): for j in range(i+1, n): if nums[i] < nums[j]: ans += 1 if k >= 3: for i in range(n): for j in range(i+1, n): for k in range(j+1, n): if nums[i] < nums[j] < nums[k]: ans += 1 a = 2 ** 61 - 1 print(ans % a)
#阿里巴巴##笔经#