hdu 5363 Key Set】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=5363 Key Set Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 549    Accepted Submission(s): 338 Problem Description soda has a set S with n integers {…
2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = 2^(n-1) - 1, 数据量大,实际就是求幂次方. 可用分治法求解.复杂度O(nlogn) // 分治法求高速幂 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int M…
HDU 3313 Key Vertex 题目链接 题意:一个有向无环图.求s,t之间的割点 思路:先spfa找一条最短路出来,假设不存在.就n个都是割点. 然后每次从s进行dfs,找到能经过最短路上的最远点.然后这个点就是割点.然后下次在以这个为起点dfs,不断迭代直到找到t为止 代码: #include <cstdio> #include <cstring> #include <vector> #include <queue> #include <a…
题 Description soda has a set $S$ with $n$ integers $\{1, 2, \dots, n\}$. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of $S$ are key set.   Input There are multiple test cases…
题 Description soda has a set $S$ with $n$ integers $\{1, 2, \dots, n\}$. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of $S$ are key set.   Input There are multiple test cases…
这个题目套公式 2^(n-1)-1,再来个快速幂基本上就可以AC了 写这个题目的: 公式容易推到错: 容易写成 2^n-1/2...这样写出来结果也不错  但是一直哇 AC: #include<iostream> #include<cstdio> #include<cstring> #define N 1000000007 using namespace std; typedef long long ll; int pow(ll x,ll y) { ll res=; w…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1885 Key Task Description The Czech Technical University is rather old — you already know that it celebrates 300 years of its existence in 2007. Some of the university buildings are old as well. And the…
题意:矩阵中'#'表示墙,'.'表示通路,要求从起点'*'到达终点'X',途中可能遇到一些门(大写字母),要想经过,必须有对应的钥匙(小写字母).问能否完成,若能,花费的时间是多少. 分析:同hdu 1429,只不过这里用map把四种钥匙标号了,否则爆内存. 错误:判断门的条件用 isupper(ch) 表示,所以终点'X'也在这个范围内. #include<cstdio> #include<cstring> #include<cctype> #include<m…
题目 之前比赛的一个题, 当时是崔老师做的,今天我自己做了一下.... 还要注意用bfs的时候  有时候并不是最先到达的就是答案,比如HDU 3442 这道题是要求最小的消耗血量伤害,但是并不是最先到达目标点的路径 就是最小的伤害,因为每一个点的伤害是 不一样的, 这种情况要用优先队列优化, 对伤害优化. 题意:*开始, X出口, b, y, r, g 代表钥匙,分别可以开B, Y, R, G颜色的门, 钥匙可以多次使用.问最短的步骤. 思路:vis[][][]数组开三维,第三维记录状态 是否拿…
题目链接 题意 : 出口不止一个,一共有四种颜色不同的门由大写字母表示,而钥匙则是对应的小写字母,当你走到门前边的位置时,如果你已经走过相应的钥匙的位置这个门就可以走,只要获得一把钥匙就可以开所有同颜色的门.问你能不能走出来. 思路 : 这个题比赛的时候完全没有思路,想了好久脑子都疼了也没想出来.原来是一个三维的BFS,因为要拿钥匙的缘故可能有些地方要来回走,所以不能像以前标记二维一样只要走过的点就不能走了,这里用三维来标记,你要是走过这个地方并且钥匙数都是一样的,那就不用再走了,因为那代表你又…