- 博客(34)
- 收藏
- 关注
原创 hdu 5312 Sequence(数学)
题目链接:hdu 5312 Sequence#include #include #include #include using namespace std;const int maxn = 1e5 + 5;const int inf = 1e9;int N, nth[maxn];bool judge (int m) { for (int i = 1; i < N
2015-07-31 23:01:43 544
原创 hdu 5305 Friends(暴力)
题目链接:hdu 5305 Friends#include #include #include using namespace std;const int maxn = 40;int N, M, ans, C[maxn], D[maxn], L[maxn], R[maxn];void init () { memset(C, 0, sizeof(C)); memse
2015-07-31 22:59:18 558 1
原创 hdu 5303 Delicious Apples(贪心)
题目链接:hdu 5303 Delicious Apples最多转一圈,所以考虑一下转一圈的情况,和直接取完回去的情况。#include #include #include #include using namespace std;typedef long long ll;const int maxn = 1e5 + 5;int L, N, K;ll d
2015-07-31 22:57:34 670
原创 hdu 5298 Solid Geometry Homework(几何)
题目链接:hdu 5298 Solid Geometry Homework每个圈或者是平面将划分出两个区域,每次把一边区域取反即可。最后判断一下是否满足。#include #include #include #include using namespace std;const int maxn = 3000;typedef long long ll;str
2015-07-31 22:43:41 802
原创 hdu 5297 Y sequence(容斥)
题目链接:hdu 5297 Y sequence考虑62以内的指数,x为奇数个质数因子,就减掉,偶数个加上。计算x为指数的不满足数直接pow(n,1/x)即可。#include #include #include #include #include #include using namespace std;typedef long long ll;cons
2015-07-31 22:15:58 753
原创 hdu 5296 Annoying problem(LCA)
题目链接:hdu 5296 Annoying problem先求出dfs序,然后每次修改一个节点u,找到dfs最接近u的两个点,a,b的dfs序分别大于和小于u的。修改值即为dp[u] - dp[lca(a,u)] - dp[lca(b,u)] + dp[lca(a, b)],dp[i]表示i到根节点的权值和。但集合中的节点的dfs序都大于或小于u时,a,b即用最大和最小的即可。
2015-07-31 21:59:40 780
原创 hdu 5295 Unstable(计算几何)
题目链接:hdu 5295 Unstable先确定B,C点,再找到A‘点A’C = AD,A'B = 2EF,然后确定G点向量A'G = CB(注意是向量)。然后根据DG = AB确定D点。三角形DAF和FBA‘为全等三角形,所以A点也可以得到。#include #include #include #include using namespace std;con
2015-07-31 21:53:28 1022
原创 hdu 5294 Tricks Device(最短路)
题目链接:hdu 5294 Tricks Device#include #include #include #include using namespace std;const int maxn = 60000 + 5;const int inf = 0x3f3f3f3f;int N, M, E, first[maxn], jump[maxn * 2], link[m
2015-07-31 21:42:28 553
原创 hdu 5293 Tree chain problem(树链剖分+树形dp)
题目链接:hdu 5293 Tree chain problem维护dp[u], sum[u],dp[u]表示以u为根节点的子树的最优值。sum[u]表示以u节点的所有子节点的dp[v]之和。对于边a,b,w,在LCA(a,b)节点的时候进行考虑。dp[u] = min{dp[u], Sum(a,b) - Dp(a,b) + sum[u] | (ab链上的点,不包括u }#
2015-07-31 21:37:10 1287
原创 hdu 5292 Pocket Cube
题目链接:hdu 5292 Pocket Cube本来想用暴力,从还原的魔方出发,遍历出所有的可能。但是看了下官方题解,挺牛逼的。考虑每个颜色对(黄,白),对于顺时为+1,逆时位-1,原位置0。总和为3的倍数就是可以还原的,否则就是不能还原。连接#include #include #include using namespace std;const int bw[
2015-07-31 21:30:21 792
原创 hdu 5290 Bombing plan(树形dp)
题目链接:hdu 5290 Bombing plandpDestroy[u][i]表示以u为根节点的子树全部被摧毁,并且向上还可以破坏到距离u为i的城市;dpSafe[u][i]表示以u为根节点的子树中有距离u深度为i的城市还未被破坏。dpDestroy[u][i] = dpDestroy[v][i+1] + sum{ min(dpDestroy[k][j], dpSafe[k][
2015-07-31 21:11:14 1295
原创 hdu 5225 Tom and permutation(回溯)
题目链接:hdu 5225 Tom and permutation#include #include #include using namespace std;typedef long long ll;const int maxn = 100;const int mod = 1e9+7;int N, ans, V[maxn + 5], A[maxn + 5];ll
2015-07-29 00:17:10 1070
原创 hdu 5125 magic balls(dp)
题目链接:hdu 5125 magic balls#include #include #include using namespace std;const int maxn = 1005;int N, M, dp[maxn][maxn], A[maxn], B[maxn];int vec[maxn][maxn], c[maxn];void init () {
2015-07-29 00:16:35 1069 1
原创 hdu 5124 lines(贪心)
题目链接:hdu 5124 lines#include #include #include #include using namespace std;typedef pair pii;int N;vector vec;int main () { int cas, x, y; scanf("%d", &cas); while (cas--) { scanf
2015-07-29 00:13:50 743
原创 hdu 5123 who is the best?(水)
题目连接:hdu 5123 who is the best?#include #include #include #include using namespace std;const int maxn = 105;int main () { int cas, n, x, c[maxn]; scanf("%d", &cas); while (cas--) {
2015-07-29 00:09:34 657
原创 hdu 5053 the Sum of Cube(水)
题目链接:hdu 5053 the Sum of Cube#include #include #include using namespace std;typedef long long ll;int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) {
2015-07-29 00:08:56 516
原创 hdu 5035 Delivery(期望)
题目链接:hdu 5035 Delivery#include #include #include using namespace std;int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) { int n; double p, s = 0; sc
2015-07-29 00:05:04 609
原创 hdu 4452 Running Rabbits
题目链接:hdu 4452 Running Rabbits#include #include #include using namespace std;const int maxn = 25;const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};const int change[4] = {2, 3, 0,
2015-07-29 00:00:47 568
原创 hdu 4450 Draw Something(水)
题目链接:hdu 4450 Draw Something#include #include #include using namespace std;int main () { int n, s, a; while (scanf("%d", &n) == 1 && n) { s = 0; for (int i = 0; i < n; i++) { sc
2015-07-28 23:56:36 551
原创 hdu 4444 Walk(预处理+暴力)
题目链接:hdu 4444 Walk#include #include #include #include #include using namespace std;const int maxn = 250;const int inf = 0x3f3f3f3f;const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0
2015-07-28 23:54:22 781
原创 hdu 4442 Physical Examination(贪心)
题目链接:hdu 4442 Physical Examination#include #include #include using namespace std;typedef long long ll;const int maxn = 100005;const ll mod = 365 * 24 * 60 * 60;struct point { ll a, b;
2015-07-28 21:14:00 594
原创 hdu 1004 Let the Balloon Rise(水)
题目链接:hdu 1004 Let the Balloon Rise#include #include #include #include #include using namespace std;const int maxn = 1005;int N;map G;int main () { while (scanf("%d", &N) == 1 && N)
2015-07-28 21:09:37 606
原创 hdu 5326 Work(水)
题目链接:hdu 5326 Work#include #include #include #include using namespace std;const int maxn = 105;int N, K, C[maxn];vector G[maxn];void init () { int u, v; memset(C, 0, sizeof(C)); fo
2015-07-28 21:08:11 588
原创 hdu 5325 Crazy Bobo(树形dp)
题目链接:hdu 5324 Crazy Bobo对于每个点,C[u]表示以u为中点(即w[u]为最小值)的满足子树,点的个数最多个数。每次一个点先优处理处C[u]。再递归向下处理。#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include usi
2015-07-28 21:03:25 958 1
原创 hdu 5323 Solve this interesting problem(dfs)
题目链接:hdu 5323 Solve this interesting problem逆向思维,每次向左或向右翻倍,知道左端点为0时,即恰好满足的情况,处理处所有情况去取最小值。#include #include #include using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3
2015-07-28 20:58:48 947
原创 hdu 5319 Painter(水)
题目链接:hdu 5319 Painter#include #include #include using namespace std;const int maxn = 55;int N;char G[maxn][maxn];bool check(char a, char b) { return a == b || a == 'G';}int solve()
2015-07-28 20:57:11 645
原创 hdu 5318 The Goddess Of The Moon(矩阵快速幂)
题目链接:hdu 5318 The Goddess Of The Moon将50个串处理成50*50的矩阵,注意重复串。#include #include #include #include using namespace std;const int maxn = 55;const int mod = 1e9+7;int N, M, A[maxn];st
2015-07-28 20:53:25 1451
原创 hdu 5317 RGCDQ
题目链接:hdu 5317 RGCDQ#include #include #include #include using namespace std;const int maxn = 1e6;int F[maxn + 5], C[maxn + 5][10];void init () { memset(F, 0, sizeof(F)); for (int i =
2015-07-28 20:50:29 633
原创 hdu 5316 Magician(线段树)
题目链接:hdu 5316 Magician线段树,区间合并,每个节点维护两端位置分别为奇奇,奇偶,偶奇,偶偶的beautiful 子串,合并的时候注意不能为空即可。#include #include #include using namespace std;typedef long long ll;const int maxn = 100005;const
2015-07-28 20:50:06 608
原创 hdu 5308 I Wanna Become A 24-Point Master(构造)
题目链接:hdu 5308 I Wanna Become A 24-Point Master#include #include #include using namespace std;int n;int main() { while (~scanf("%d", &n)) { if (n == 1 || n == 2 || n == 3) prin
2015-07-28 20:45:23 681
原创 hdu 5301 Buildings
题目链接:hdu 5301 Buildings#include #include #include using namespace std;int solve(int a, int b, int c) { return max(a, min(b, (c+1)/2));}int main () { int n, m, x, y; while (scanf("%d%
2015-07-28 20:45:12 649
原创 hdu 5291 Candy Distribution(dp)
题目链接:hdu 5291 Candy Distribution每次先计算出dp[0],然后根据dp[0]的数值可以用o(1)的复杂度算出dp[1],以此类推。总体复杂度为o(200 * 80000),可以接受。#include #include #include using namespace std;const int maxn = 80000;const int maxm
2015-07-28 20:42:49 817
原创 hdu 5289 Assignment(数学)
题目链接:hdu 5289 Assignment#include #include #include using namespace std;const int maxn = 100000 + 5;const int maxm = 20;int N, K, A[maxn], dMax[maxn][maxm], dMin[maxn][maxm];void RmqInit()
2015-07-28 20:33:54 783
原创 hdu 5288 OO’s Sequence(two point + rmq)
题目链接:hdu 5288 OO’s Sequence#include #include #include #include using namespace std;const int maxn = 1e4 + 5;const int maxm = 1e5 + 5;const int mod = 1e9 + 7;int N, v[maxm], a[maxm], l[max
2015-07-28 20:30:48 620
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人