随笔分类 -  容斥原理

摘要:【链接】 "我是链接,点我呀:)" 【题意】 在这里输入题意 【题解】 让你求出1..n中和m互质的位置i. 让你输出∑ai 这个ai可以oeis一波。 发现是ai = i (i+1) 1..n中和m互质的数字的个数之前有做过一题。 然后发现是逆着做的。 删掉不互质的。剩下的就是互质的了。 是用容斥 阅读全文
posted @ 2018-09-11 11:40 AWCXV 阅读(153) 评论(0) 推荐(0) 编辑
摘要:time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given three sticks with posit... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(185) 评论(0) 推荐(0) 编辑
摘要:time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mike is a bartender at Rico’s bar. A... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(172) 评论(0) 推荐(0) 编辑
摘要:Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4384 Accepted Submission(s): 1733P... 阅读全文
posted @ 2017-10-04 18:45 AWCXV 阅读(115) 评论(0) 推荐(0) 编辑
摘要:【题目链接】:http://codeforces.com/contest/803/problem/F【题意】 给你一个序列; 问你这个序列里面有多少个子列; 且这个子列里面的所有数字互质; 【题解】 计算cnt[x]; 表示数组里有多少个数是x的倍数; 则某个子列里面所有的数字都... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(122) 评论(0) 推荐(0) 编辑
摘要:【题目链接】:http://hihocoder.com/problemset/problem/1476【题意】 【题解】 首先不考虑黑格子,计算出一共有多少个矩形: 枚举矩形的大小r×c,这样大小的矩形一共有(N−r+1)(M−c+1)个。 然后减去不符合要求的矩形,也就是减去包含... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(406) 评论(0) 推荐(0) 编辑
摘要:【链接】http://acm.hdu.edu.cn/showproblem.php?pid=6106【题意】给出选 A,B,C,AB,AC,BC,ABC 课程的学生,其中 AB 是 A 和 B 都选….,确定该班级的人数,给出的数据中有一些数错误的,但保证一组正确答案,输出最多的班级的人数【题解】除... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(117) 评论(0) 推荐(0) 编辑
摘要:【Link】:http://acm.hdu.edu.cn/showproblem.php?pid=6053【Description】 给你一个b数组,让你求一个a数组; 要求,该数组的每一位都小于等于b数组; 且这个b数组的n个数的gcd>=2 【Solution】 设f[i]表... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(125) 评论(0) 推荐(0) 编辑
摘要:【题目链接】:http://acm.hdu.edu.cn/showproblem.php?pid=4135【题意】 让你求a..b中与n互质的数的个数. 【题解】 可以用前缀和转化为求1..x内与n互质的数的个数; 先求出n的所有的质因子; 然后设1..x内为第i个质因子的倍数的... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(83) 评论(0) 推荐(0) 编辑
摘要:【题目链接】:http://acm.uestc.edu.cn/#/problem/show/1544【题意】 【题解】 容斥原理题; 1..(2^m)-1枚举 设k为其二进制形式中1的个数; k为奇数 ans+=2^(k-1)*(n/lcm(对应的k个数)) 否则-=….. 如果不... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Problem StatementYou are given two ints: n and m. Let D be the number of permutations of the set {1,2,…,n+m} such that the first m values are ... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(110) 评论(0) 推荐(0) 编辑
摘要:【题目链接】:http://acm.hdu.edu.cn/showproblem.php?pid=4135【题意】 让你求出[a..b]这个区间内和N互质的数的个数; 【题解】 利用前缀和,求出[1..a-1]和a[1..b]这两个区间内和N互质的数的个数; 方法是; 从小到大求... 阅读全文
posted @ 2017-10-04 18:44 AWCXV 阅读(66) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示