
2018多校
hao_zong_yin
有问题可以加QQ讨论2987048728,备注一下优快云
展开
-
HDU 6304 Chiaki Sequence Revisited——计数问题
题意:n=1,2时,a[n] =1;n>=3时,a[n] = a[n-a[n-1]] + a[n-1-a[n-2]];现在给定一个n(1<=n<=1e18),求前a的前n项和,结果mod(1e9+7)思路:大体思路:找规律->求出a[n]->求出a的前n项和详细思路:打表打出a后发现序列是这样的 1 1 2 2 3 4 4 4 5 6 6 ...原创 2018-07-24 12:16:38 · 441 阅读 · 0 评论 -
hdu 6357 Hills And Valleys——dp
题意:给你一串数,你可以反转任意一个区间,也可以不反转,使得反转后整个串的LIS最长,输出LIS长度以及反转的区间(spj)思路:因为每个数的数值只有0~9,所以可以从数值出发,枚举反转区间的值域【x, y】,根据这个值域可以构造一个串:{0,1,...x}{y,y-1,...x}{y,y+1,...9},设原串为A,新构造的串为B,那么只要求A和B的LCS就可以了(注意这个LCS稍微特殊...原创 2018-08-07 17:37:51 · 299 阅读 · 0 评论 -
HDU 6400 Parentheses Matrix——构造
10 10的时候这么构造是14(()()()())()()()()()......()()()()()(()()()())但是下面这么构造是16((((((((((()()()()()......()()()()()))))))))))也就是说我们可以通过破坏首尾两行来获得更多的匹配列其余情况同理#include <cstdi...原创 2018-08-15 19:21:46 · 204 阅读 · 0 评论 -
HDU 6350 Always Online——仙人掌图
思路:把每个环的最小边去掉,加在环的其他边上,然后并查集跑一下就可以,跑的时候维护一下某位为1的点有多少个#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;typedef unsigne...原创 2018-08-08 17:28:15 · 346 阅读 · 0 评论 -
HDU 6370 Werewolf——思路题
vector卡到绝望。。。。。。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>using namespace std;const int maxn = 1e5 + 10;int mem...原创 2018-08-09 01:42:32 · 546 阅读 · 0 评论 -
HDU 6395 Sequence——分段矩阵快速幂
我是直接爆1~1e5,后面的分段矩阵快速幂,和我做法类似的可以拿我的代码去对拍#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod = 1e9 + 7;const ll sz = 1e5;ll A, B, C, D, P, n, F[sz+10];struct Mat...原创 2018-08-14 00:47:15 · 294 阅读 · 0 评论 -
HDU 6435 Problem J. CSGO
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const ll INF = 1e16;int T, n, m, k, a[5];ll sum[(1&l...原创 2018-08-22 20:23:17 · 217 阅读 · 0 评论 -
HDU 6434 Problem I. Count
#include<bits/stdc++.h>using namespace std;#define LL long longconst int N = 2e7;const int maxn = N+10;int T,n;int primes,prime[maxn],phi[maxn];bool vis[maxn];LL ans[maxn];void init...原创 2018-08-22 22:14:49 · 232 阅读 · 0 评论 -
HDU 6415 Rikka with Nash Equilibrium——dp
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 81;int T, n, m, mod;ll dp[2][maxn][...原创 2018-08-20 21:40:28 · 249 阅读 · 0 评论 -
HDU 6356 Glad You Came——ST表
线段树区间更新会超时,可以考虑用ST表的区间更新方法,更新区间[l, r]时,假设len = log2(r-l+1),则相当于更新[l,l+(1<<len)-1]和区间[r-(1<<len)+1, r],可以在O(1)时间内完成一次更新。最后求解的时候从大到小逐层下推即可。#include <cstdio>#include <cstring>...原创 2018-08-06 21:16:57 · 223 阅读 · 0 评论 -
HDU 6333 Problem B. Harvest of Apples——莫队
题意:There are nn apples on a tree, numbered from 11 to nn. Count the number of ways to pick at most mm apples. 思路:sum(n, m) = 2sum(n-1, m) - c(n-1, m)sum(n,m) = sum(n, m-1) + c(n, m)可以发现若知道了...原创 2018-08-05 16:20:32 · 249 阅读 · 0 评论 -
HDU 6299 Balanced Sequence——贪心
题意:给定n个串,要求将这n个串按照一定的顺序拼接,使得最终串合法子序列长度之和最长思路:注意到每个串去掉所有匹配子串后剩下的一定是"))((("这种类似的形式,所以我们可以先预处理去掉每个串的匹配子串,顺便统计到结果里,剩下的部分就可以用两个数表示,我这里用l表示")"的数量,用r表示'('的数量,然后按照以下规则排序:假定两个串s1, s2要比较顺序,则,若s1.l >...原创 2018-07-24 15:15:39 · 221 阅读 · 0 评论 -
HDU 6298 Maximum Multiple——水题
题意:Given an integer nn, Chiaki would like to find three positive integers xx, yy and zz such that: n=x+y+zn=x+y+z, x∣nx∣n, y∣ny∣n, z∣nz∣n and xyzxyz is maximum.思路:优先1/3, 1/3, 1/3, 然后1/2, 1/4, 1/...原创 2018-07-24 15:52:23 · 318 阅读 · 0 评论 -
HDU 6301 Distinct Values——优先队列
题意:Chiaki has an array of nn positive integers. You are told some facts about the array: for every two elements aiai and ajaj in the subarray al..ral..r(l≤i<j≤rl≤i<j≤r), ai≠ajai≠aj holds. Chi...原创 2018-07-24 19:46:38 · 203 阅读 · 0 评论 -
HDU 6305 RMQ Similar Sequence——笛卡尔树
题意:Chiaki has a sequence A={a1,a2,…,an}A={a1,a2,…,an}. Let RMQ(A,l,r)RMQ(A,l,r) be the minimum ii (l≤i≤rl≤i≤r) such that aiai is the maximum value in al,al+1,…,aral,al+1,…,ar. Two sequences AA and ...原创 2018-07-25 01:22:15 · 474 阅读 · 0 评论 -
HDU 6315 Naive Operations——线段树
题意: In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permutation of 1 to n. Initially a is filled with zeroes. There are two kind of operations: 1. a...原创 2018-07-26 00:45:30 · 268 阅读 · 0 评论 -
HDU 6313 Hack It——构造
题意:构造一个矩阵,使得不存在这样一个子矩阵,子矩阵的四个角都为1思路:首先用常用的数论构造方法,假设n=5^2,那么矩阵可以写作这种形式:xxxxx xxxxx xxxxx xxxxx xxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxx xxxxx xxxxx xxxxx xxxxx...原创 2018-07-26 11:20:29 · 295 阅读 · 0 评论 -
HDU 6318 Swaps and Inversions——逆序对
交换一对元素对前后的逆序对数没有影响,按照这个思路最终得到答案为逆序对数*min(x,y)#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const...原创 2018-07-26 11:43:16 · 216 阅读 · 0 评论 -
HDU 6311 Cover——欧拉路径
题意:给你一个图,问你最少几次一笔画可以画完思路:将同一连通块中的每对奇数点连边,跑出欧拉路径后断开刚才连的边,剩下的边就是结果注意细节,首先判掉孤立点,然后注意有奇数点的时候别全连了,留两个,毕竟我们跑的是欧拉路径而不是欧拉回路,没奇数点的时候就随便跑了#include <cstdio>#include <cstring>#include <...原创 2018-07-26 20:40:00 · 519 阅读 · 1 评论 -
HDU 6319 Problem A. Ascending Rating——单调队列
思路:因为要求的是1~n-m+1号元素的值,所以倒着维护简单,因此倒着建一个单调递减的单调队列就可以了,最大值即队首元素,数量即队列的元素个数#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;...原创 2018-08-05 20:37:59 · 193 阅读 · 0 评论