容斥原理
coldfresh
那我们开始吧
展开
-
GCD HUD 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 only原创 2017-07-18 23:18:09 · 393 阅读 · 0 评论 -
【51nod 1678】 lyk与gcd(容斥、筛法)
基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题这天,lyk又和gcd杠上了。它拥有一个n个数的数列,它想实现两种操作。1:将 ai 改为b。2:给定一个数i,求所有 gcd(i,j)=1 时的 aj 的总和。Input第一行两个数n,Q(1<=n,Q<=100000)。接下来一行n个数表示ai(1<=ai<=10^4).原创 2018-09-29 19:48:38 · 389 阅读 · 0 评论 -
【HDU - 5468 】Puzzled Elena(容斥)
Since both Stefan and Damon fell in love with Elena, and it was really difficult for her to choose. Bonnie, her best friend, suggested her to throw a question to them, and she would choose the one who...原创 2018-09-14 14:47:11 · 227 阅读 · 0 评论 -
17年ACM/ICPC亚洲区域赛现场赛乌鲁木齐站(D题和K题)
这次在乌市现场赛的关键是D题和K题,就这两个问题来实际探讨一下。 就比赛前一刻,我突然想起前1到n的平方和1到n的平方和,然后我问东东通向公式是多少,最后我还是想起来,但是没想到,在比赛的时候还真的用着了。这是题外话,咳咳。 由于题目资源放在计蒜客平台上,而且要到明年2月才开放,所以只能拿自己在现场赛的纸质题目了… D题: 题目大意就是在一个圆上,在其圆周上放置n个点,问最多原创 2017-12-16 22:50:59 · 1072 阅读 · 0 评论 -
GCD Expectation ZOJ - 3868 (容斥)
Edward has a set of n integers {a1, a2,…,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has equal probability to be picked), and would like to know the expectation of [gc...原创 2018-04-25 17:23:17 · 239 阅读 · 0 评论 -
Color UVALive - 7040 (容斥+组合数)
Recently, Mr. Big recieved n owers from his fans. He wants to recolor those owers with m colors. The owers are put in a line. It is not allowed to color any adjacent owers with the same color. Flowers原创 2017-10-24 23:38:25 · 331 阅读 · 0 评论 -
TrickGCD HDU - 6053(莫比乌斯函数与容斥的关系)
You are given an array AA , and Zhu wants to know there are how many different array BB satisfy the following conditions? 1≤Bi≤Ai For each pair( l , r ) (1≤l≤r≤n) , gcd(bl,bl+1…br)≥2 Input The firs原创 2017-10-22 15:26:28 · 469 阅读 · 0 评论 -
Sticks and Right Triangle HDU - 3939(毕达哥拉斯)
We have a stick with infinite length. Now we want to cut 3 sub-sticks with length x, y, z which is not large than L to form a right triangle. With unknown reasons we assume that x, y, z are all integer原创 2017-09-29 19:08:53 · 320 阅读 · 0 评论 -
Lucky7 HDU - 5768(中国剩余定理+容斥定理)
When ?? was born, seven crows flew in and stopped beside him. In its childhood, ?? had been unfortunately fall into the sea. While it was dying, seven dolphins arched its body and sent it back to the s原创 2017-09-03 14:09:47 · 393 阅读 · 0 评论 -
HDU 4135 Co-prime(容斥原理)
Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime if they have no com原创 2017-07-19 14:44:36 · 421 阅读 · 0 评论 -
【CodeForces - 1139D】Steps to One(期望dp,容斥)
Vivek initially has an empty array a and some integer constant m.He performs the following algorithm:1.Select a random integer x uniformly in range from 1 to m and append it to the end of a.Compute...原创 2019-05-09 19:45:13 · 328 阅读 · 0 评论