- 博客(70)
- 收藏
- 关注

原创 自勉
作为一只生于大浙江的蒟蒻,初中时开始接触OI,在这之前,从来没想过自己有一天能理直气壮的在机房搞这样一门帅气的竞赛,最初是因为好奇,也因为觉得是玩玩电脑就入了坑,后来就真正爱上了OI,曾经有人和我说,OI和文化课不矛盾,我也一直坚信,但是后来由于自己浪的太嗨,文化课成绩还是跌了,但是我知道,这并不是因为OI,到了高中,我们的任课老师似乎总是对信息学竞赛抱有偏见,当然,也和我们略难堪的文化课成绩有直
2016-11-02 22:15:14
592
原创 「NOIP2017模拟赛09.10」绝对值
题目链接:暂无题目描述:给一个数xx,求y≥2y\ge2满足 ·|x−y||x-y|最小 ·yy的质因子数中每个质因子恰好均出现两次 数据范围: ·数据组数T(1≤T≤50)T(1\le T\le50) ·1≤x≤10181\le x\le10^{18}根据题意可知yy是个完全平方数,那么只根据y√\sqrt{y}来求范围就降到10910^9 然后从y√\sqrt y向两头枚举,不用担心
2017-09-11 21:13:54
379
原创 CODECHEF Fill The Matrix
题目链接:https://www.codechef.com/SEPT17/problems/FILLMTR 首先明确没有限制的格子不需要管,那么只需要去管那些限制就好了 而只要那些限制之间不产生矛盾,就一定存在合法序列 欧拉回路判断是否有矛盾产生 贴代码#include<cstdio>#include<cstring>using namespace std;const int maxn
2017-09-11 19:55:59
320
原创 CODECHEF Sereja and Commands
题目链接:https://www.codechef.com/SEPT17/problems/SEACO 树状数组,倒着处理 因为数字更新可能为负,所以取模要注意 贴代码#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long ll;const int maxn=1
2017-09-11 19:41:02
406
原创 CODECHEF Minimum Good Permutation
题目链接:https://www.codechef.com/SEPT17/problems/MINPERM 求最小的错排 奇偶要分类讨论 偶数个时把[1,n][1,n]两两分组,每组两个交换,如[1,2][1,2],[3,4][3,4]等 偶数个时前面一样,后面三个特殊处理,n−2,n−1,nn-2,n-1,n变成n−1,n,n−2n-1,n,n-2 贴代码#include<cstdio>
2017-09-11 19:29:49
341
原创 排列组合部分及应用
组合数意义nn个元素中取出m(m≤n)m(m\le n)个元素,不考虑元素排列顺序,满足条件的方案数记为CmnC_{n}^{m}写法CmnC_{n}^{m}可以记为nCmnCm或C(n,m)C(n,m)或(nk)\binom{n}{k}公式Cmn=Pmnm!=n!m!(n−m)!=Cn−mn=Cm−1n−1+Cmn−1C_{n}^{m}=\frac{P_{n}^{m}}{m!}=\frac{n!}{
2017-09-09 16:29:46
4533
原创 「NOIP2017模拟赛09.07」不解释连招
题目链接:http://hhhoj.ngrok.cc/contest/4/problem/11 贪心思想,ciwi\frac{c_{i}}{w_{i}}的值越大,说明这个技能越强,能用则用 那么问题来了,也许会出现这样的情况,你还漏下一些空不好塞,但拿掉些个大的,用一些小的可以刚好填满,并满足情况最优,于是乎就出现了一些纠结 如果看完题目,不难发现,突破口在于1≤wi≤31\le w_{i}\
2017-09-08 22:55:05
457
原创 「NOIP2017模拟赛09.07」虐场
题目链接:http://hhhoj.ngrok.cc/problem/10 非常显而易见,要晚点挂,就要尽可能和菜鸟比,要赢得第ii场比赛,就要满足是2i2^{i}个人中的最大值,注意虽然平局结果是随机的,但为了达到最优情况,应当判为胜,不要遗漏 贴代码#include<cstdio>#include<cstring>#include<algorithm>using namespace s
2017-09-08 22:23:26
433
原创 51NOD1277 字符串中的最大值
题目链接:传送门 kmp裸题 因为前缀是从长到短覆盖的,所以从长到短累计加和 贴代码 var s:ansistring; n,i,j:longint; a:array[0..100005]of char; f,p:array[0..100005]of longint; ans:int64; begin// assign(input,'1277.in
2017-09-06 23:01:42
341
原创 HDU1686 Oulipo
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686 kmp裸题 网上kmp的解法很多,讲了一大通很复杂的样子,偶然看到一股清流,很好懂,很清楚,写法有点变通,但更容易理解记忆,传送门%%%matrix67 贴代码 var p:array[0..1000005]of longint; a,b:array[0..100000
2017-09-05 23:37:52
387
原创 HDU1358 Period
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1358 KMP自己匹配自己 pip_i为最大kk满足k<ik<i ∧\land a1∼ka_{1\sim k}与aa的后缀匹配 若成立,循环数为i/(i−pi)i/(i-p_{i}) 贴代码 var a:array[0..1000005]of char; p:array[
2017-09-05 21:39:56
209
原创 HDU6146 Pokémon GO
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6146 先考虑从(1,1)开始走的方案数,有如下几种情况 那么从第一列出发的方案数就可算了,乘以2即可 令gi=2i−1g_{i}=2^{i-1} 则方案数pi=2∗fi−1+4∗fi−2+gi+1p_{i}=2*f_{i-1}+4*f_{i-2}+g_{i+1} 但是第一种情况中,起始点和
2017-08-24 20:47:33
302
原创 「NOIP2017模拟赛08.11」sequence
题目链接:暂无题目描述 给出一个n项数列{an},求其和大于等于k的最长连续子序列的长度。 输入格式 第一行两个整数 n,k。 第二行 n 个整数ai 。 输出格式 输出一行答案。 样例输入 5 -1 3 0 -3 -4 2 样例输出 3 数据规模与约定 对于前 20% 的数据,1 ≤ n ≤ 100 对于前40
2017-08-24 18:44:22
251
原创 HDU6144 Arithmetic of Bomb
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6144 字符串的展开+大数取模 由于不存在括号套括号的鬼畜神奇情况,所以直接模拟即可附大数取模: len:=length(ss); ans:=0; for i:=1 to len do ans:=(int64(ans)*10+ord(ss[i])-48)mod tt;贴代码 const tt=10
2017-08-24 18:32:30
278
原创 HUU6147 Pokémon GO II
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6147 感觉算是百度之星2017复赛最简单的一道题了 画个图就可以发现规律 因为是按照一个方向转的,那么在不存在路径覆盖的情况下,转圈只能越来越大或越来越小,而且在这种一圈圈包含的情况下,若要路径覆盖,只能和上一级进行覆盖,如图示 那么每一条线段只可能和前8段进行路径覆盖(实际上会更小),枚举
2017-08-23 23:09:24
352
原创 CODECHEF Palindromic Game
题目链接:https://www.codechef.com/problems/PALINGAM 算是博弈论的题,但主要就是猜结论+乱搞 可以一步步考虑 第一步没有什么输赢 第二步如果B给出了A给出的字符就赢了,那么如果A中所有出现过的字符都在B中出现过,则B稳赢 第三步如果A给出了第一步给出的字符就赢了,当然前提是第二步B未赢,所以如果A中存在一个出现次数≥2的字符且
2017-08-20 08:35:24
243
原创 BZOJ1613 [Usaco2007 Jan]Running贝茜的晨练计划
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1613 水题,DP f[i][j]表示第i秒末疲劳度为j时的最大跑步距离 那么两种情况,跑步和休息 休息也分两种情况,疲劳度>0和疲劳度=0 转移方程很好推,见代码 贴代码#include#includeusing namespace std;i
2017-08-15 23:16:32
334
原创 HDU1018 Big Number
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 求n!长度 求x十进制下长度为trunc(lg(x))+1 因为lg(x*y)=lg(x)+lg(y) 所以1~n枚举一下把lg(i)相加最后向下取整加一就是答案 贴代码 var i,j,n,x:longint; ans:double; begin
2017-08-03 18:07:17
292
1
原创 「NOIP2017模拟赛08.02」A**B
题目链接:http://hhhoj.ngrok.cc/contest/3/problem/4 高精度乘法 小数点位数加一下就好了 注意前后的0以及输出规范 贴代码 type arr=array[0..300]of longint; var s:string; n,x,bo,i,j,t,len,bo1:longint; ans,a:arr
2017-08-02 22:06:36
776
原创 「NOIP2017模拟赛07.31」倒水
题目链接:http://hhhoj.ngrok.cc/problem/7 挺有意思的一道题,反正我第一反应二分 无所畏惧.jpg 非常显而易见的,要中和就要有温度差,且Tmin和Tmax中和后的温度为(Tmin,Tmax) 那么只有以下3种情况有解: 1、大水缸的T>Tmax 2、大水缸的T 3、所有温度相等,此时答案为0,而且不需要特判,只要在判定前两种
2017-07-31 23:06:58
417
原创 POJ3253 Fence Repair
题目链接:http://poj.org/problem?id=3253 和合并果子一样,小根堆 贴代码#include#includeusing namespace std;typedef long long ll;const int maxn=20005;ll heap[maxn];int len,n;void swap(ll &x,ll &y){ ll t;
2017-07-25 10:53:29
191
原创 HDU2066 一个人的旅行
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2066 把与家相邻的地方与N+1相连,边长为0 把想到的地方与N+2相连,边长为0 N为所出现的数字的Max 刷N+1到N+2的最短路,单源最短路刷Dijkstra 贴代码#include#includeusing namespace std;const int
2017-07-24 23:34:28
245
原创 HDU1874 畅通工程续
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 最短路裸题,点很小,可以用Floyd 而且是单源最短路,也可以用Dijkstra(见下) 贴代码#include#includeusing namespace std;const int maxn=205;int g[maxn][maxn],d[maxn];boo
2017-07-24 22:58:19
165
原创 HDU2544 最短路
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 最短路裸题,点数小,可以直接用Floyd求解 贴代码#include#includeusing namespace std;int g[105][105];int main(){// freopen("2544.in","r",stdin);// freopen("2
2017-07-24 22:19:19
239
原创 HDU1068 Girls and Boys
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 最大独立集,匈牙利 贴代码#include#includeusing namespace std;const int maxn=1505;int son[maxn*maxn*2],nxt[maxn*maxn*2];int link[maxn],check[maxn];
2017-07-16 15:41:17
264
原创 HDU2063 过山车
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2063 二分图匹配,匈牙利 贴代码#include#include#includeusing namespace std;const int maxn=505,maxe=1005;int son[maxe*2],nxt[maxe*2];int link[maxn*2],che
2017-07-16 15:36:40
263
原创 HDU1968 Just a Hook
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1698 线段树,整段更新,有些细节注意 贴代码#include#includeusing namespace std;const int maxn=100005;int tree[maxn*10];int Q,n,m;void build(int root,int L,int
2017-07-12 20:33:58
287
原创 HDU1754 I Hate It
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 线段树 此题空间极小,注意爆空间 如果开数组,延迟标记就算了= =,左右下标也算了,直接递归带参数跑= = 贴代码#include#includeusing namespace std;const int maxn=200005;int tree[maxn*2
2017-07-11 19:39:15
275
原创 HDU1166 敌兵布阵
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166 线段树裸题,注意数组大小为nlogn 贴代码#include#includeusing namespace std;const int N=50005;int a[N];//addflag[N],int addflag[N*20],tree[N*20],left[20*
2017-07-10 21:23:33
206
原创 BZOJ 3016: [Usaco2012 Nov]Clumsy Cows
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3016 比较有意思的一道题,似乎哪次打ACM的时候碰到过类似的 算是贪心题吧 括号匹配,首先()为合法,假设A是某个合法的, 那么一个合法的被一个合法的嵌套是合法的,如(A) 以及两个合法的并列仍合法,如AA 由嵌套合法可以推想到一个很显然的想法:已合法的
2017-07-09 20:01:24
261
原创 POJ3090 Visible Lattice Points
题目链接:http://poj.org/problem?id=3090 和一道叫兔八哥什么的题是差不多的 涉及到网格图上的一个问题:判断(x1,y1)和(x2,y2)的连线上有没有其它格点 当gcd(|x1-x2|,|y1-y2|)=1时,是满足要求的 所以就是结合线性筛,用欧拉函数phi搞一搞就好了 贴代码#include#includeusing name
2017-07-08 15:14:15
249
原创 POJ1284 Primitive Roots
题目链接:http://poj.org/problem?id=1284 原根,定义题面有 暴力枚举肯定会TLE 找规律,用欧拉函数,答案为phi(n-1) 附:原根的百度百科 一篇关于原根看起来很厉害的博客 鸣谢博主ACdreamerACdreamer
2017-07-07 22:02:55
234
原创 POJ2407 Relatives
题目链接:http://poj.org/problem?id=2407 欧拉函数 已知n求phi(n)但是此处n是不包括在内的 贴代码#include#includeusing namespace std;typedef long long ll;int main(){ freopen("2407.in","r",stdin); freopen("2407.out
2017-07-07 20:34:23
263
原创 POJ1990 MooFest
题目链接:http://poj.org/problem?id=1990 树状数组,统计的时候显然不可以一对一对地加上去 可以先按照v[i]升序 当前位置前后面分类讨论,所以用两个树状数组,一个统计个数,一个统计距离,可以通过作差计算,注意不要算岔了 贴代码#include#include#include #includeusing namespace std;
2017-07-07 17:08:13
244
原创 POJ2029 Get Many Persimmon Trees
题目链接:http://poj.org/problem?id=2029 二维树状数组+容斥 c[i][j]的意义是(i,j)为右下角的前缀和 注意要向上统计,向下修改 注意区别单点修改与区间修改 贴代码#include#includeusing namespace std;int const maxn=105;int c[maxn][maxn];int
2017-07-06 22:08:15
243
原创 POJ3067 Japan
题目链接:http://poj.org/problem?id=3067 求交叉数,先按第一列排序,再对第二列求逆序对 注意会爆int 注意==和=,一不留神写错还没看出来 贴代码#include#include#include#includeint const maxn=1005;int a[maxn*maxn],b[maxn*maxn],c[maxn];i
2017-07-06 19:59:18
245
原创 POJ2155 Matrix
题目链接:http://poj.org/problem?id=2155 树状数组+容斥,注意要向上统计,向下修改 注意c[x][y]的意义是A[i][j]修改后的值 贴代码#include#include#include#includeusing namespace std;int const maxn=1005;int c[maxn][maxn];int Q,
2017-07-06 17:00:07
246
原创 BZOJ2227: [Zjoi2011]看电影(movie)
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2227 组合数学,加上一个位置,可以看成是一个环,方案数(k+1)^n,是环就可以转,那么就有k+1个方案重复,故实际方案数为(k+1)^(n-1),再把这个位置去掉,方案数为k+1-n,所以对于这个问题本身来说,方案数为(k+1)^n·(k+1)^(n-1),总方案数为k^n,则概率
2017-03-13 14:17:01
483
原创 【区间覆盖】土地改革
题目大意:有一些长度不均匀的线段分布在一个一维的轴上,这些线段间存在相交但不存在包含,要求把一些线段修剪,使之最终满足每个线段最后变成其子线段,且每个线段长度相等。求出这些线段最大可能的长度,用最简分数表示。 思路1:
2017-03-09 15:15:30
277
原创 BZOJ3668: [Noi2014]起床困难综合症
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3668 OR,XOR,AND都是位运算,其运算结果相当于转化成二进制之后每位分别进行该项位运算,每位之间是相互独立,不存在进位,而在二进制下只存在0/1,所以可以把它看成一个二进制数,从最高位开始扫,每一位分别用0/1试一下是否可行,每次取当前位在合法情况下尽可能的大值(即尽可能取1)
2017-02-13 18:59:03
312
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人