自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

原创 POJ - 3254 Corn Fields【状压dp模板】

状压dp就是将一个状态压缩成一个十进制数,再进行状态转移。一般是把一行数据按照合适的进制转化为一个整数。1、一般来说需要先预处理出来所有可行的状态,判断可行可以用位运算对状态进行操作。2、然后预处理出第一行的状态。3、从第二行开始遍历每一行,枚举第i行的所有可行状态,枚举第i-1行的所有可行状态,判断其与本行是否冲突,状态间是否冲突。再进行转移。对于本题,判断k状态是否与本行冲突,我们可以将本行的...

2018-04-30 13:56:52 89

原创 HDU - 4638 Group【莫队】

GroupTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3080    Accepted Submission(s): 1540Problem DescriptionThere are n men ,every man has an ID...

2018-04-28 17:46:37 102

原创 2018年湘潭大学程序设计竞赛 H 统计颜色【线段树+状态压缩】

时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述 n个桶按顺序排列,我们用1~n给桶标号。有两种操作:1 l r c 区间[l,r]中的每个桶中都放入一个颜色为c的球 (1≤l,r ≤n,l≤r,0≤c≤60)2 l r   查询区间[l,r]的桶中有多少种不同颜色的球     (1≤l,r ≤n,l...

2018-04-27 10:08:32 296 4

原创 2018年湘潭大学程序设计竞赛 G 又见斐波那契【矩阵快速幂】

时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述 这是一个加强版的斐波那契数列。给定递推式求F(n)的值,由于这个值可能太大,请对109+7取模。输入描述:第一行是一个整数T(1 ≤ T ≤ 1000),表示样例的个数。以后每个样例一行,是一个整数n(1 ≤ n ≤ 1018)。输出描述:每个样例...

2018-04-27 08:53:12 180

原创 01字典树模板

01字典树在异或问题的查询上十分高效。01字典树是按位插入和查询的。因为如果一个数,它的高位值较大,那么这个数的值较大。所以我们插入和查询时是从最高位开始进行的。可以开一个辅助数组val来记录原数值。插入:#define ll long longint n,m;int trie[32*MAXN][2];ll val[32*MAXN];int tot;void insert(ll d){...

2018-04-26 16:17:16 1545 2

原创 字典树模板

字典树(trie树)是一种根据前缀在log(n)左右时间内完成查询的数据结构。可以添加辅助数组来完成特定功能。插入:int trie[MAXN][50],sum[MAXN];//sum记录单词出现的次数char buf[MAXN][50];int tot;//给节点编号void insert(char str[]){ int root=0; for(int i=0;str[...

2018-04-26 15:42:29 272

原创 POJ - 1988 Cube Stacking 【带权并查集】

Cube StackingTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 27036 Accepted: 9482Case Time Limit: 1000MSDescriptionFarmer John and Betsy are playing a game with N (1 <= N <= 30,000)ide...

2018-04-26 10:13:20 157

原创 FZU - 2271 X 【floyd】

Problem 2271 XAccept: 290    Submit: 1158Time Limit: 1500 mSec    Memory Limit : 32768 KB Problem DescriptionX is a fully prosperous country, especially known for its complicated transportation networ...

2018-04-25 20:52:34 218

原创 FZU - 2267 The Bigger the Better

 Problem 2267 The Bigger the BetterAccept: 118    Submit: 802Time Limit: 1500 mSec    Memory Limit : 32768 KB Problem DescriptionFat brother and Maze are playing a kind of special (hentai) game with t...

2018-04-25 19:59:28 212

转载 素数判定的一些讨论(Miller-Rabin算法)

很久没有写博客了。。。最近军训加开学,感觉刷题速度有降低,要补一补。回归正题,正式进入数论阶段,讨论一下关于素数判定的那些事。一类问题: 判定一个整数n(n>1)是否为素数。Miller-Rabin算法:这是一种随机性素数判定算法,也就是说,答案可能出错,但是可能性极小。先是讲两个定理:费马小定理: 对于一个质数pp,取任意整数aa,满足gcd(p,a)=1gcd(p,a)=1,则有 ap−...

2018-04-24 17:52:29 698

转载 湖北省程序设计竞赛 A. Srdce and Triangle

链接:https://www.nowcoder.com/acm/contest/104/A来源:牛客网题解:画辅助线 构造一个等边三角形,然后就可以证出图中 三角形1 和三角形 2是全等的(边角边,初中数学我竟然没想到)显然橙色三角形就是我们要求的三角形了,所以 可以求出一个角度为 减60°,其他两个角同理;附上ac代码:#include<stdio.h> #include<...

2018-04-24 11:17:06 346

原创 2018 ACM-ICPC B. Goldbach【java快速判断素数】

Description:Goldbach's conjecture is one of the oldest and best-known unsolved problems in number theory and all of mathematics. It states:Every even integer greater than 2 can be expressed as the sum...

2018-04-23 14:04:28 159

原创 SCU - 4488 king's trouble II 【dp/单调栈】

DescriptionLong time ago, a king occupied a vast territory.Now there is a problem that he worried that he want to choose a largest square of his territory to build a palace.Can you help him?For simpli...

2018-04-18 21:54:07 148

原创 SCU - 4489 misaka and last order【枚举因子】

Time Limit: 1000 MS Memory Limit: 131072 K DescriptionMisaka Mikoto is a main character of the Animation "To Aru Majutsu no Index" and "To Aru Kagaku no Railgun". She was enrolled into t...

2018-04-18 17:05:27 288

原创 POJ - 1324 Holedox Moving【状态压缩+A*】

Holedox MovingTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 17742 Accepted: 4175DescriptionDuring winter, the most hungry and severe time, Holedox sleeps in its lair. When spring comes, Ho...

2018-04-17 17:48:35 170

原创 最长回文子串-Manacher算法模板

模板:#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define MAXN 2000005int n,ans,p[MAXN];char str[MAXN];void Manacher(){ int mx=0,id=0; n=n*...

2018-04-14 21:12:28 127

原创 OpenJ_Bailian - 4124 海贼王之伟大航路【dfs+状态压缩】

题目链接:点击打开链接思路:记忆化搜索。可以用一个14位的二进制进行状态压缩。第i位为1表示走过第i个点。由于起点和终点不用标记,所以只需要14位。dp[i][j]记录已经走过了i状态的点,并且当前在j点的最短路。代码:#include<stdio.h>#include<string.h>#include<algorithm>#include<mat...

2018-04-13 18:00:30 294

原创 CKOJ 1071: zdw的嘤嘤嘤【维护前缀变量】

1071: zdw的嘤嘤嘤时间限制: 1 Sec  内存限制: 128 MB提交: 52  解决: 13[提交][状态][讨论版]题目描述//感觉会被zdw揍众所周知,zdw是一个萌妹,喜欢嘤嘤嘤。而且最擅长八重嘤和嘤雄不朽。这一天zdw说了一个很长的字符串,只包括 ‘y’ , ‘i’ , ‘n’ ,’g’这四个字符。你需要选取尽量多的下标,让这些下标在这个字符串中对应的字符按下标从小到大的顺序组...

2018-04-13 10:20:59 290

原创 CKOJ 1072: 简单的问题【组合数学】

1072: 简单的问题时间限制: 1 Sec  内存限制: 128 MB提交: 21  解决: 5[提交][状态][讨论版]题目描述这个问题太简单了以至于出题人想不到什么捏造什么背景了(脑洞缺失那就让我们直奔主题吧:给你一个n,你能否知道,在[0,n)中,有多少数的二进制表示中1的个数和n的二进制表示中1的个数是一样多的?输入:第一行一个T,表示有T组数据其后T行,每行一个整数,代表n输出:n行每...

2018-04-13 09:56:57 379

原创 Aizu - ALDS1_13_C 15 Puzzle【A* 八数码】

Heuristic Search - 15 PuzzleTime Limit : 3 sec, Memory Limit : 262144 KB Japanese version is here15 PuzzleThe goal of the 15 puzzle problem is to complete pieces on 4×44×4 cells where one of the cells...

2018-04-11 20:53:29 313

原创 Educational Codeforces Round 41 (Rated for Div. 2)D. Pair Of Lines

D. Pair Of Linestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points on Cartesian plane. Every point is a lattice point (i. e. b...

2018-04-10 20:10:09 105

原创 Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama【树状数组】

E. Tufuramatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Polycarp decided to rewatch his absolute favourite episode of well-known TV ser...

2018-04-10 15:47:19 121

原创 树状数组求逆序数【模板】

树状数组模板转到 点击打开链接可以用 c[i] 记录小于 i 的数字的个数。这个可以利用树状数组的特性,每添加一个数字i,向其父节点更新(父节点一定大于i),可以在log(n)的时间内完成更新。sum(i) 查询1~i区间内的小于i的个数。计算逆序数的时候只需要用i-sum(i)就行了。如果给出的数字范围过大,还需要进行离散化。离散化时需要记录其原本的位置。给出一个经过离散化的模板:#includ...

2018-04-10 14:18:12 206

原创 树状数组【模板】

树状数组(BIT)是能够完成下述操作的数据结构。给定i,计算a1+a2+...ai给定i和x,执行ai+=x可以利用前缀和的思想计算任意区间的和。详细讲解参考《挑战程序设计(第2版)》P175计算节点的父节点int lowbit(int x){ return x&(-x);}修改节点void add(int i,int x){ while(i<=n) {...

2018-04-09 08:29:50 3918 1

原创 Number Sequence【矩阵快速幂】

Number SequenceTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 192483    Accepted Submission(s): 48142Problem DescriptionA number sequence is de...

2018-04-07 10:26:13 286

原创 Instant Complexity

Instant ComplexityTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2375 Accepted: 821DescriptionAnalyzing the run-time complexity of algorithms is an important tool for designing efficient pr...

2018-04-06 17:58:29 143

原创 Making the Grade【dp+离散化】

Making the GradeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8774 Accepted: 4104DescriptionA straight dirt road connects two fields on FJ's farm, but it changes elevation more than FJ wou...

2018-04-06 16:44:26 159

原创 Space Elevator【多重背包】

Space ElevatorTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12769 Accepted: 6071DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a g...

2018-04-06 15:34:37 157

原创 Bridging signals 【二分优化LIS,模板】

Bridging signalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 15368 Accepted: 8321Description'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once mo...

2018-04-06 11:05:12 321

原创 地形编辑器【前缀和】

1066: 地形编辑器时间限制: 1 Sec  内存限制: 128 MB提交: 30  解决: 3[提交][状态][讨论版]题目描述zdw很喜欢玩红警, 他经常制作一些奇奇怪怪的红警地图当他制作地图的时候, 经常需要用到地形编辑器zdw可以用这个编辑器将地图上的某个区域的高度改变x来创造地形一次显然是不够的, 而经过若干次的操作后, 地图上将会出现各种山脉和峡谷现给出zdw的所有操作, 求这些操作...

2018-04-06 09:44:02 387 1

原创 Brackets【区间dp】

BracketsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10537 Accepted: 5580DescriptionWe give the following inductive definition of a “regular brackets” sequence:the empty sequence is a reg...

2018-04-04 21:57:06 157 1

原创 Cheapest Palindrome【区间dp】

Cheapest PalindromeTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 11768 Accepted: 5571DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to ...

2018-04-04 21:03:43 76

原创 Milking Time

Milking TimeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12088 Accepted: 5106DescriptionBessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that s...

2018-04-04 19:41:00 219

原创 Dollar Dayz【dp+java高精度】

Dollar DayzTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8535 Accepted: 3191DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. ...

2018-04-03 21:31:34 139

原创 Apple Catching

Apple CatchingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14191 Accepted: 6938DescriptionIt is a little known fact that cows love apples. Farmer John has two apple trees (which are conve...

2018-04-03 19:53:02 384

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除