C - To Be an Dream Architect Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3682 Appoint description:  System Crawler  (2014-11-05) Description The “dream architect” is the key role in a team o…
C - To Be an Dream Architect Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3682 Appoint description:  System Crawler  (2014-11-09) Description The “dream architect” is the key role in a team o…
Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. When Hogwarts school is in holiday, Harry Potter has to go back to uncle Vernon's home. But he can't bring his precious with him. As you know, uncle Ve…
F - Rotational Painting Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3685 Appoint description:  System Crawler  (2014-11-09) Description Josh Lyman is a gifted painter. One of his great works…
H - National Day Parade Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3687 Appoint description:  System Crawler  (2014-11-08) Description There are n×n students preparing for the National Day…
F - Computer Virus on Planet Pandora Time Limit:2000MS     Memory Limit:128000KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3695 Appoint description:  System Crawler  (2014-11-05) Description     Aliens on planet Pandora also write…
Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There are n courses, the ith course is available during the time interval (A i,B i). That means, if you…
Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem: ABBDE __ ABCCC = BDBDE In the equation above, a letter stands for…
Description “Farm Game” is one of the most popular games in online community. In the community each player has a virtual farm. The farmer can decide to plant some kinds of crops like wheat or paddy, and buy the corresponding crop seeds. After they gr…
In geometry the Fermat point of a triangle, also called Torricelli point, is a point such that the total distance from the three vertices of the triangle to the point is the minimum. It is so named because this problem is first raised by Fermat in a…
Description Harry: "But Hagrid. How am I going to pay for all of this? I haven't any money." Hagrid: "Well there's your money, Harry! Gringotts, the wizard bank! Ain't no safer place. Not one. Except perhaps Hogwarts." ― Rubeus Hagrid…
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages of finding a new route to India. As you know, just in those voyages, Columbus discovered the America…
题意:有N(1<=N<=20)张卡片,每包中含有这些卡片的概率,每包至多一张卡片,可能没有卡片.求需要买多少包才能拿到所以的N张卡片,求次数的期望. 析:期望DP,是很容易看出来的,然后由于得到每张卡片的状态不知道,所以用状态压缩,dp[i] 表示这个状态时,要全部收齐卡片的期望. 由于有可能是什么也没有,所以我们要特殊判断一下.然后就和剩下的就简单了. 另一个方法就是状态压缩+容斥,同样每个状态表示收集的状态,由于每张卡都是独立,所以,每个卡片的期望就是1.0/p,然后要做的就是要去重,既然…
题意: 给你一个有n个点的树,给定根,叫你找第k大的特殊链 .特殊的链的定义:u,v之间的路径,经过题给的根节点. 题解:(来自BC官方题解) 对于求第k大的问题,我们可以通过在外层套一个二分,将其转化为求不小于mid的有多少个的问题. 接下来我们讨论如何求树上有多少条折链的长度不小于k. 我们考虑常规的点分治(对于重心,求出其到其他点的距离,排序+单调队列),时间复杂度为O(nlog^2n),但是这只能求出普通链的数量. 我们考虑将不属于折链的链容斥掉.也即,我们需要求出有多少条长度不小于mi…
听了杜教的直播后知道了怎么做,有两种方法,一种构造函数(现在太菜了,听不懂,以后再补),一种容斥原理. 知识补充1:若x1,x2,.....xn均大于等于0,则x1+x2+...+xn=k的方案数是C(k+m-1,m-1)种(貌似紫书上有,记不太清了). 知识补充2:若限制条件为n(即x1,x2....xn均小于n,假设有c个违反,则把k减掉c个n(相当于把c个超过n的数也变成大于等于0的),就可以套用知识1的公式了. 则最后的答案为sum( (-1)^c * C(m , c) * C(m-1+…
A. Reverse 菜鸡wwb又不会了..... 可以线段树优化建边,然而不会所以只能set水了 发现对于k和当前反转点固定的节点x确定奇偶性所到达的节点奇偶性是一定的 那么set维护奇偶点,然后每次set找点删点注意边界 set在删点后原来的迭代器会玄学出错,xuefeng好像被坑了,所以lowerbound一下就不用++了 B. Silhouette 很玄学的容斥 考场多QJ了18分,因为如果1-n是个序列,好像就是一个简单的容斥..... 然后用能发现是以"L"形的形状向右推的…
杭州现场赛的题.BFS+DFS #include <iostream> #include<cstdio> #include<cstring> #define inf 9999999 using namespace std; char mp[105][105]; int sq[5][5]; int step[4][2]={{0,1},{1,0},{0,-1},{-1,0}}; struct pos { int x,y; }; int n,m,prn,x,y,tmp,ans…
题目链接  2017 CCPC Hangzhou Problem G 题意描述很清晰. 考虑每个家庭有且仅有$k$对近亲的方案数: $C(a, k) * C(b, k) * k!$ 那么如果在第$1$个家庭里面选出$k_{1}$对近亲,在第$2$个家庭里面选出$k_{2}$对近亲......在第$n$个家庭里面选出$k_{n}$对近亲, 剩下那些人自由组合的话,那么最后这种方案至少会有$∑k$对近亲. 说是至少,因为同一个家庭里面没被强行选择的男女还是可能被组到了一起. 那么考虑如何求至少有$k…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5514 题意:有m个石子围成一圈, 有n只青蛙从跳石子, 都从0号石子开始, 每只能越过xi个石子.问所有被至少踩过一次的石子的序号之和. 题解:根据裴蜀定理每个青蛙可以跳到的最小石子编号为 gcd(xi,m) = bi,所有小于 m 的 bi 的倍数都是可以到达的石头.显然所有 bi 都为 m 的因子,标记 m 中所有能到达的因子,进行容斥,比如因子2.3.6都可以到达,计算 2 和 3 的倍数的时…
A Simple Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5794 Description There is a n×m board, a chess want to go to the position (n,m) from the position (1,1). The chess is able to go to position (x2,y2) from the position (x1,y1), only and if…
Frogs Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5514 Description There are m stones lying on a circle, and n frogs are jumping over them.The stones are numbered from 0 to m−1 and the frogs are numbered fro…
Frogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1315    Accepted Submission(s): 443 Problem Description There are m stones lying on a circle, and n frogs are jumping over them.The stones a…
D - GCD HDU - 1695 思路: 都 除以 k 后转化为  1-b/k    1-d/k中找互质的对数,但是需要去重一下  (x,y)  (y,x) 这种情况. 这种情况出现 x  ,y 肯定 都在 min  (b/k, d/k)  ,所以 奇数 最后 减去 一半 即可. #include<bits/stdc++.h> using namespace std; #define ll long long #define maxn 1234567 bool vis[maxn+10];…
C - Visible Trees HDU - 2841 思路 :被挡住的那些点(x , y)肯定是 x 与 y不互质.能够由其他坐标的倍数表示,所以就转化成了求那些点 x,y互质 也就是在 1 - m    1 - n 中找互质的对数,容斥 求一下即可 #include<bits/stdc++.h> using namespace std; #define ll long long #define maxn 123456 bool vis[maxn+10]; ll t,n,m,prime[m…
Y sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5297 Description Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hates those numbers which can be written as a^b (a, b are positive integers,2…
http://acm.hdu.edu.cn/showproblem.php?pid=1695 要求[L1, R1]和[L2, R2]中GCD是K的个数.那么只需要求[L1, R1 / K]  和 [L2, R2 / K]中GCD是1的对数. 由于(1, 2)和(2, 1)是同一对. 那么我们枚举大区间,限制数字一定是小于等于枚举的那个数字就行. 比如[1, 3]和[1, 5] 我们枚举大区间,[1, 5],在[1, 3]中找互质的时候,由于又需要要小于枚举数字,那么直接上phi 对于其他的,比如…
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #define LL long long using namespace std; ; ; LL Factor[],cnt,n,m,tot,Rev,Kase,Prime[Maxn]; bool vis[Maxn]; inline LL Quick_Pow(LL x,LL y) { LL Ret=; whi…
hdu 5792 要找的无非就是一个上升的仅有两个的序列和一个下降的仅有两个的序列,按照容斥的思想,肯定就是所有的上升的乘以所有的下降的,然后再减去重复的情况. 先用树状数组求出lx[i](在第 i 个数左边的数中比它小的数的个数),ld[i](在第 i 个数左边的数中比它大的数的个数),rx[i](在第 i 个数右边的数中比它小的数的个数) ,rd[i](在第 i 个数右边的数中比它大的数的个数).然后重复的情况无非就是题目中a与c重合(rx[i]*rd[i]),a与d重合(rd[i]*ld[…
How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4249    Accepted Submission(s): 1211 Problem Description   Now you get a number N, and a M-integers set, you shoul…
GCD 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1695 Description 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…