题解 SGU294 He's Circles】的更多相关文章

题目描述 失踪人口回归 根据\(Polya\)定理$$ans=\frac 1n \sum\limits_{i=1}^n2^{gcd(i, n)}$$ 考虑枚举\(gcd\),原式变成$$\frac 1n \sum\limits_{d|n}2^d\sum\limits_{i=1}^n\big[gcd(i,n)=d\big]$$ 用\(id\)替换\(i\) $$\frac 1n \sum\limits_{d|n}2^d\sum\limits_{i=1}^{\frac nd}\big[gcd(i,\…
[题解]CIRU - The area of the union of circles [SP8073] \ 圆的面积并 [Bzoj2178] 传送门: \(\text{CIRU - The area of the union of circles [SP8073]}\) 圆的面积并 \(\text{[Bzoj2178]}\) [题目描述] 给出 \(n\) 个圆的圆心坐标 \((x,y)\) 和半径 \(r\),求它们覆盖的总面积. [输入] 第一行一个整数 \(n\),表示一共有 \(n\)…
[题意] 如果两个人互相打电话(直接或者间接),则说他们在同一个电话圈里.例如,\(a\)打给\(b\),\(b\)打给\(c\),\(c\)打给\(d\),\(d\)打给\(a\),则这四个人在同一个圈里:如果\(e\)打给\(f\),而\(f\)不打给\(e\),则不能推出\(e\)和\(f\)在同一个电话圈.输入\(n(n≤25)\)个人的\(m\)次电话,找出所有的电话圈.人名只包含字母,不超过\(25\)个字符,且不重复. [算法] \(Floyd\text{传递闭包}\) [分析]…
---------- HDU 5288 OO’s Sequence 题意 给定一个数列(长度<$10^5$),求有多少区间[l,r],且区间内有多少数,满足区间内其它数不是他的约数. 数的范围$[1,10000]$.结果对$10^9+7$取模. Solution 首先可以预处理每个数的约数有哪些.对每个数存下它的位置有哪些. 然后可以枚举每一个位置,利用二分找到左边第一个是它约数的数,和右边第一个是他约数的数. 假设向左有L个数,向右有R个数.那么ans应该加上(L*R). 时间复杂度$O(n*…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. 先将这五题的题解放上来,剩余题目等搞出来再补上 A题 A Curious Matt Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Problem Description T…
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对应的随笔下面评论区留言,我会及时处理,在此谢过了. 过程或许会很漫长,也很痛苦,慢慢来吧. 编号 题名 过题率 难度 1 Two Sum 0.376 Easy 2 Add Two Numbers 0.285 Medium 3 Longest Substring Without Repeating C…
原题链接在这里:https://leetcode.com/problems/friend-circles/description/ 题目: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direc…
Circles Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5299 Description There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent. Alice and…
好久没来写了,继续继续... Easy(250pts): //前方请注意,样例中带有zyz,高能预警... 题目大意:给你一个字符串,中间有一些是未知字符,请你求出这个字符串的回文子串个数的期望值.数据满足字符最多2500个. 我们考虑每一个子串,它对答案的贡献度就是它是回文串的概率,那么我们扫一遍就可以了, 这样做时间复杂度O(n^3),显然过不去. 我们考虑一下对于一个子串,在判断其是回文串的时候,我们一定是从中间往两边扫的,那么其实中间这些子串我们已经统计过答案了, 也就是说,我们通过枚举…
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of…