HDU 4705 Y】的更多相关文章

Y Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 433    Accepted Submission(s): 147 Problem Description   Sample Input 4 1 2 1 3 1 4   Sample Output 1 Hint 1. The only set is {2,3,4}. 2. Ple…
Y Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 60    Accepted Submission(s): 20 Problem Description   Sample Input 4 1 2 1 3 1 4   Sample Output 1 Hint 1. The only set is {2,3,4}. 2. Please…
树形枚举--搜索 题目描述: 给你一棵树,要在一条简单路径上选3个不同的点构成一个集合,问能构成多少个不同的集合. 解法: 枚举所有结点,假设某个结点有n棵子树,每棵子树的结点个数分别为s1,s2,````sn.那么在选中该结点后,剩下的两个结点从子树上选,考虑顺序,则有方案数ans =  s1*(sum(si) - s1) + s2*(sum(si) - s2) + ``` + sn*(sum(si) - sn),化简得ans = sum(si) ^ 2 - sum(si ^2) .实际上,另…
Description Input 4 1 2 1 3 1 4 题目的意思是给你一棵树,让你找到所有不在一条路径上的三个点的情况个数.乍一看正向处理比较麻烦,我们从反方向考虑,如果是取在一条路径上的3个点,那又该怎样取呢?我们以Num[rt]表示以rt为根的子树上的节点的个数(包括根节点).选取方法是这样的,先把一个树的树根选上,然后看他每一个亲儿子作为树根时,子树有几个节点(Num[son1],Num[son2],Num[son3]...)对于son1来说,能选取Num[son1]中的任意一点…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4705 #pragma comment(linker, "/STACK:16777216") #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #i…
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=4705 思路:反面考虑,用总的方案数减去A,B,C三点在同一路径上的方案数.于是我们可以确定中间点B,在当前以B为根求得的son中任选一个,在剩下的节点n-tmp-1(tmp为已经求得的B的儿子的个数)中任选一个,产生tmp*(n-tmp-1)中组合. #include<iostream> #include<cstdio> #include<cstring> #include…
DP:求出3点构成链的方案数 .然后总方案数减去它 Y Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1738    Accepted Submission(s): 493 Problem Description   Sample Input 4 1 2 1 3 1 4   Sample Output 1 Hint 1. The…
题意:给定正整数n和r.定义Y数列为从正整数序列中删除全部能表示成a^b(2 ≤ b ≤ r)的数后的数列,求Y数列的第n个数是多少. 比如n = 10. r = 3,则Y数列为2 3 5 6 7 10 11 12 13 14,第10个数是14. 非常有趣的一道数论题.题目给出的范围是long long范围的. 所以显然不用去枚举每一个数了,更不用说推断每一个数是不是某个数的某次方.那么这个题怎么下手呢.首先我们能够非常直观的想到,被删去的数显然是非常分散的.由于能表示成某个数的幂这种形式的数非…
思路:枚举能是A,B,C在一条简单路径上的中点. 计算多少个几何能满足.在用总数减去 #pragma comment(linker, "/STACK:16777216") #include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #inclu…