- 博客(34)
- 收藏
- 关注
转载 poj1222(高斯消元解XOR方程(模2方程))
传送门 ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) #define inf 2000000000 using namespace std; typedef long long ll; //---------------------head const i...
2018-10-07 21:44:00
238
转载 hdu5072(容斥,互质判断,同色三角形模型)
传送门 解答传送门 ac代码(位运算实现容斥原理): #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll inf =233...
2018-09-24 22:33:00
281
转载 hdu4135(容斥原理求质数,队列实现)
传送门 ac代码(队列实现版本): #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll inf =2333333333...
2018-09-22 15:31:00
224
转载 poj2559(单调栈)
传送门 写法一: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll inf =2333333333333333L...
2018-09-22 00:23:00
162
转载 poj2796(单调栈)
传送门 实测如果有多个值相等,输出最后一个最大值的LR ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll i...
2018-09-19 14:48:00
233
转载 icpc2018焦作Transport Ship(背包思想)
传送门 ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll inf =2333333333333333LL; ...
2018-09-16 11:41:00
192
转载 icpc2018焦作Mathematical Curse(动态规划)
传送门 ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; //#define int long long const ll inf =2333333333333333LL; ...
2018-09-15 21:26:00
154
转载 2018icpc徐州OnlineA Hard to prepare
src:https://nanti.jisuanke.com/t/31453 解答传送门 ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) #define mod 1000000007 using namespace std; typedef long long...
2018-09-14 11:53:00
158
转载 icpc2018徐州OnlineG-Trace(线段树)
传送门 首先计算宽度,维护一棵线段树存之前扫描过的线段中时间比当前边大的长度 于是可以线段树下标为时间,值为长度,因为线段树要做到子节点的信息能往上传。如果下标为长度,值为时间,我们就不能动态地计算时间大于 t 时的长度! ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i...
2018-09-12 20:47:00
217
转载 hdu3499(分层图最短路 or 反向建图)
传送门 方法一:分层图 #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) #define mod 1000000007 using namespace std; typedef long long ll; const ll inf =23333333333333333L...
2018-09-06 11:57:00
193
转载 ccpc2018Online
hdu6438-hdu6447 左转官方题解 1001Buy and Resell(思维) i点和它后面的谁交易不影响答案,如样例一中的(10-1 + 9-2)=(9-1 + 10-2) 考虑第 i 天是否卖出,一定是在左边列的前 i - 1 个中找一个还未配对的最小值和其配对进行买卖获益最大,如果最小值 >= 当前第 i 天的价格就不交易。用堆维护已买的东西,对...
2018-08-25 23:42:00
178
转载 bzoj4173数学(欧拉函数)
解答:https://blog.youkuaiyun.com/popoqqq/article/details/46820313 https://blog.youkuaiyun.com/zhhx2001/article/details/52300924 倒数第二行的拓展(借用某群提问的一个问题): 对于d*phi(d),当d为k时,在左式,他出现在 i 为k,2k,3k...(n/k)*k...
2018-08-24 23:17:00
158
转载 数论小总结
质(素)数 : 任何数都能表示为质数的乘积,这应该是由质数的概念决定的,因为质数指:“质数(prime number)又称素数,有无限个。质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数。” ,所以合数肯定等于质数*某数,而某数又可以用这样的规则拆分成质数的乘积! 另外有这样一个定理,如果a,x与n互质,则a*x与n互质!!! 因为a,x,n拆分成质数后,a,x与n拆...
2018-08-21 00:01:00
137
转载 poj2096(概率dp)
src:http://poj.org/problem?id=2096 题意: 一个软件有s个子系统,会产生n种bug 某人一天发现一个bug,这个bug属于一个子系统,属于一个分类 每个bug属于某个子系统的概率是1/s,属于某种分类的概率是1/n 问发现n种bug,每个子系统都发现bug的天数的期望。 解答:https://blog.youkuaiyun.com/morgan_xww/art...
2018-08-17 23:23:00
196
转载 bzoj4318/洛谷P1654OSU!(期望dp,立方版本)
src:https://www.luogu.org/problemnew/show/P1654 解答:https://oi.men.ci/bzoj-4318/ 方法同平方版本 思路:求期望,如求E(f[i]),我们要确定 f[ i ] 有几种可能,这里的可能就是pi和1-pi两种,然后各种情况的期望乘上各种情况的可能性大小 x表示i-1位置的连续长度,f[i-1] = E(x^3...
2018-08-17 23:22:00
169
转载 hdu1027(逆康托展开)
src:http://acm.hdu.edu.cn/showproblem.php?pid=1027 一开始已经提过了,康托展开是一个全排列到一个自然数的双射,因此是可逆的。即对于上述例子,在(1,2,3,4,5)给出61可以算出起排列组合为 34152。由上述的计算过程可以容易的逆推回来,具体过程如下: 用 61 / 4! = 2余13,说明a[5]=2,说明比首位小的数有2个...
2018-08-16 11:52:00
261
转载 hdu3734(数位dp,相减抵消影响)
src:http://acm.hdu.edu.cn/showproblem.php?pid=4734 注意dp的状态定义,第二个参数用all-sum,是因为这样就可以不用每个case重复memset dp,因为all-sum就消去了每次all值不同的影响!!! ac代码: #include<bits/stdc++.h> using namespace std; ...
2018-08-15 16:13:00
152
转载 hdu2089(数位dp模版)
src : http://acm.hdu.edu.cn/showproblem.php?pid=2089 前导零:前导零 是一种 显示数字前面的0的一种格式,比如:000,222.340这样 的好处是 格式对齐..比如我们要求是3位数的 数字001002003..010011.这样有前导零 会更好记录和排序 ac代码: #include<bits/stdc++.h&...
2018-08-15 14:24:00
111
转载 hdu2856(倍增lca模版题)
ac代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,b) for(int i=a;i <= b;i++) #define Max(a,b) a=max(a,b) #define Min(a,b) a=min(a,b) #define Sz(x) (int)x.size() ...
2018-08-13 22:42:00
202
转载 百度之星2018初赛Bt4 P1m2(二分答案)
src:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=826&pid=1004 可以用某值来判断是否满足题意时 可以用二分答案的方法! 代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,b) ...
2018-08-12 22:50:00
145
转载 高亮测试
typedef long long ll; int a[20]; ll dp[20][state];//不同题目状态不同 ll dfs(int pos,/*state变量*/,bool lead/*前导零*/,bool limit/*数位上界变量*/)//不是每个题都要判断前导零 { //递归边界,既然是按位枚举,最低位是0,那么pos==-1说明这个数我枚举完...
2018-08-09 10:28:00
94
转载 hdu5834(树形dp,dfs两次规划)
src:http://acm.hdu.edu.cn/showproblem.php?pid=5834 题意:给定一棵树,有点权和边权,点权上的价值只能取一次,多次通过边要花费多次边权,求以每个节点为起点能获得的最大价值。 思路:第一次dfs,得到各节点往下的最大价值,然后第二次dfs考虑父节点的影响,将无根树转化成有根树考虑,实现方式有多种!!! 我的实现方式在求次优路有点麻烦,...
2018-08-08 16:11:00
274
转载 百度之星2018资格赛t6三原色图(MST minimum spanning tree)
ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; const int mod=998244353; const int inf =0x3f3f3f3f; const do...
2018-08-05 22:25:00
142
转载 百度之星2018资格赛t1调查问卷(状压dp)
一般n比较大,状态数m(这里10)比较小时适合状态压缩成0...1到111..1这样1<<m个状态!!! 也就是暴力枚举所有子集~ ac代码: #include<bits/stdc++.h> #define per(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long lo...
2018-08-05 14:48:00
118
转载 N多校2018d5t6 take(概率)
src :https://www.nowcoder.com/acm/contest/143/F https://blog.youkuaiyun.com/Lee_w_j__/article/details/81367134 思路:对于每个宝石对于答案的贡献都是独立的。 ac代码: 转载于:https://www.cnblogs.com/WindFreedom/p/9418211.htm...
2018-08-04 12:03:00
95
转载 poj2104(主席树。k_th number)
src :http://poj.org/problem?id=2104 ac代码: #include <bits/stdc++.h> using namespace std; #define per(i,a,b) for(int i=a;i<=b;i++) #define MP make_pair typedef pair<int,int>...
2018-08-01 12:50:00
93
转载 N多校2018d3t10 Hash Function
理解hash过程 首先可知,先放进去肯定是h[i]%n==i的位置,这些个位置放进set按照字典序顺序来,然后每安排一个这样点,对于它后一位的值,如果还没被放入set,则如果它%对应的位置已经放入set了则它放入set ~ ac代码: #include <bits/stdc++.h> using namespace std; #define per(i,a...
2018-07-29 14:41:00
134
转载 N多校2018d4t7Maximum Mode
多动手写思路才能让思维更加清晰吖~~~ 例2 2 3 3 4 首先用map记录每个数出现次数mp[2]=mp[3]=2 , mp[4]=1; 然后t【】记录每个次数的个数; 然后从大到小扫描频率,记录如果答案是某频率,至少去掉多少点(这里要去掉的最少点<=m没关系,如果m>min的话,去掉除该值的其他数就可以了) 然后扫描各个值,得到最大值 ac代码: #...
2018-07-28 21:57:00
136
转载 poj1442(treap求第k大)
ac代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,b) for(int i=a;i <= b;i++) #define Max(a,b) a=max(a,b) #define Min(a,b) a=min(a,b) #define Sz(x) (int)x.size() ...
2018-07-27 21:18:00
192
转载 poj3481(treap)
注意判断指针空就用NULL,不要用!p ~~~ ac代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,b) for(int i=a;i <= b;i++) #define Max(a,b) a=max(a,b) #define Min(a,b) a=min(a,b) #...
2018-07-27 17:14:00
220
转载 N多校2018d3t1 PACM Team(多维背包+记录路径)
注意记录路径时path要五维,不能滚动数组,因为没有第几个物品来标明顺序的话,就可能在某个物品的dp中导致path 的两个状态对应同一个物品,导致wa或者超时! 还有dp数组可以用short int存储 ac代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,b) for(int i=...
2018-07-26 20:00:00
221
转载 hdu5726(ST表+二分)
src:http://acm.hdu.edu.cn/showproblem.php?pid=5726 解答:http://www.cnblogs.com/WABoss/p/5686994.html 代码: #include<bits/stdc++.h> using namespace std; #define per(i,a,n) for(int i=a...
2018-07-25 13:29:00
260
转载 hdu5592(权值线段树)
题意:你知道有一个1~n的排列,但具体排列你不知道。现在给出1~n每个前缀的逆序数对数,让你还原这个排列。 思路:从最后一个值开始考虑,rev[i]-rev[i-1]表示前面比它大的数的个数,我们就可以得出当前位置的数字在1-n中的次序,然后进行权值线段树的操作~~~ ac代码 #include <iostream> #include<stdio.h&...
2018-07-20 17:19:00
199
转载 poj2723Get Luffy Out 2-sat问题
Problem Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there,...
2018-03-12 16:38:00
253
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅