解题思路:
全排列,然后筛选,但是超时了。。。。。。
注意事项:
参考代码:
from itertools import permutations n,k = map(int,input().strip().split()) A = [i for i in range(1,n+1)] rst = permutations(A) ans = 0 item = 1 while True: try: cnt = 0 item = next(rst) for i in range(1,n-1): if item[i-1] < item[i] > item[i+1] or item[i-1] > item[i] < item[i+1]: cnt = cnt + 1 if cnt == k-1: ans = (ans + 1) % 123456 except: break print(ans)
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:546 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:646 |
Hello, world! (C语言代码)浏览:826 |
陶陶摘苹果2 (C语言代码)浏览:601 |
JAM计数法 (C语言代码)浏览:671 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:720 |
1199题解浏览:656 |
Manchester-A+B for Input-Output Practice浏览:1789 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:488 |
Manchester- 校门外的树浏览:3230 |