随笔分类 -  容斥原理

摘要:传送门:http://codeforces.com/contest/839/problem/D Examples input 33 3 1 output 12 input 42 3 4 6 output 39 Note In the first sample the clans are {1}, { 阅读全文
posted @ 2017-08-17 13:20 Meternal 阅读(214) 评论(0) 推荐(0)
摘要:题意:从1到n+m的数组中选m个数字且每个数字和在原数组中下标不同,求方案数。例如 n=1 m = 2 则存在{2,1},{2,3},{3,1} 题解:错排问题模板 下面是使用容斥原理推导的过程 1. 先推导标准的错排公式 假设为从1到m的m个数字组成的数组 令k=非错排的数字个数 共有m!种情况, 阅读全文
posted @ 2017-07-02 14:20 Meternal 阅读(306) 评论(0) 推荐(0)