莫比乌斯 && 容斥原理
Printf()
这个作者很懒,什么都没留下…
展开
-
筛法专题(莫比乌斯函数、欧拉函数、素数三合一)
此筛法复杂度为O(n)级别 const int maxn = 1e7 + 100; int tot; int mu[maxn], prime[maxn], phi[maxn]; bool vis[maxn]; void Mubius() { phi[1] = 1; //如果不需要筛欧拉函数的话所有的计算phi[i]的步骤都删去即可 mu[1] = 1; //求莫比乌斯函...原创 2018-12-22 10:43:54 · 480 阅读 · 0 评论 -
GCD HDU - 1695 (容斥原理 + 欧拉函数)
Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, you're...原创 2018-12-03 16:38:42 · 205 阅读 · 0 评论 -
How many integers can you find HDU - 1796 (容斥原理)
Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer...原创 2018-12-01 10:32:48 · 253 阅读 · 0 评论 -
容斥定理
对容斥定理不算太理解,在此贴上一道例题体会一下(山东省第九届ACM省赛F题) Problem Description Given l1,r1,l2,r2,l3,r3,l4,r4l_1,r_1,l_2,r_2,l_3,r_3,l_4,r_4l1,r1,l2,r2,l3,r3,l4,r4, please count the number of four-tuples (x1,x2,...原创 2018-05-24 20:20:36 · 189 阅读 · 0 评论 -
给定x属于[1, a] 和y属于[1, b],求gcd(x, y) == 1的(x, y)的数量(莫比乌斯函数)
#include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; const int maxn = 1e5 + 100; int n, tot, m; int prime[maxn], mu[maxn]; bool vis...原创 2018-12-22 14:26:30 · 767 阅读 · 0 评论 -
Sum HDU - 4407(分解质因数 + 容斥)
XXX is puzzled with the question below: 1, 2, 3, ..., n (1<=n<=400000) are placed in a line. There are m (1<=m<=1000) operations of two kinds. Operation 1: among the x-th number to the y...原创 2018-12-25 09:24:36 · 184 阅读 · 0 评论