
简单算法
DlPF_C
这个作者很懒,什么都没留下…
展开
-
HDU 5929 Basic Data Structure 双向队列
Mr. Frog learned a basic data structure recently, which is called stack.There are some basic operations of stack: ∙∙ PUSH x: put x on the top of the stack, x must be 0 or 1. ∙∙ POP: throw the elemen...原创 2018-07-19 10:16:55 · 237 阅读 · 0 评论 -
Coin 2017ICPC西安网络赛
原题链接:https://nanti.jisuanke.com/t/17115Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is \frac{q}{p}(\frac{q}{p} \le \frac{1}{2})pq(p原创 2017-09-16 20:03:15 · 533 阅读 · 0 评论 -
HDU 6158 The Designer 笛卡尔定理+韦达定理 2017ccpc网络赛
The DesignerTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1198 Accepted Submission(s): 233Problem DescriptionNowadays, litt原创 2017-08-23 16:29:01 · 559 阅读 · 0 评论 -
POJ1753 Flip Game 位运算+搜索
Flip GameTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 46458 Accepted: 19890DescriptionFlip game is played on a rectangular 4x4 field with two-sided原创 2017-08-23 15:59:12 · 322 阅读 · 0 评论 -
UVA - 10285 Longest Run on a Snowboard
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1226DFS+记忆化搜索#include#define N 105#define INF 200int maps[N][N];int ans[N][N];int dfs(int原创 2017-08-25 14:27:39 · 365 阅读 · 0 评论 -
CodeForces - 793B Igor and his way to work dfs搜索
B. Igor and his way to worktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWoken up by the alarm clock Igo原创 2017-08-25 11:31:05 · 373 阅读 · 0 评论 -
CodeForces - 53D Physical Education
D. Physical Educationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is a school PE teacher. Unlike原创 2017-08-14 20:48:39 · 478 阅读 · 0 评论 -
CodeForces - 96B
Lucky Numbers (easy)搜索,因为数字只有4和7,所以搜索量不大,思路简单,但不好想,看代码。#includelong long n,s;void search(long long a,int x,int y)//x表示4的数量,y表示7的数量{ if(a>=n&&x==y&&(a<s||!s)) s=a; if(a<n*100) {原创 2017-08-14 20:34:30 · 313 阅读 · 0 评论 -
CodeForces - 276B Little Girl and Game
B. Little Girl and Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Girl loves problems on g原创 2017-07-28 20:09:46 · 1542 阅读 · 0 评论 -
CodeForces - 276C Little Girl and Maximum Sum
C. Little Girl and Maximum Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe little girl loves the pr原创 2017-07-28 19:56:41 · 526 阅读 · 0 评论 -
CodeForces - 678D Iterated Linear Function
D. Iterated Linear Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a linear function f(x)原创 2017-07-28 17:28:06 · 402 阅读 · 0 评论 -
51Nod - 1089 最长回文子串 V2(Manacher算法)
1089 最长回文子串 V2(Manacher算法)基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。输入一个字符串Str,输出Str里最长回文子串的长度。Input输入Str(Str的长度 Output输出最长回文原创 2017-07-28 19:21:58 · 247 阅读 · 0 评论 -
CodeForces - 455A Boredom
A. Boredomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex doesn't like boredom. That's why whenever he原创 2017-07-28 17:07:06 · 511 阅读 · 0 评论 -
CodeForces - 701C They Are Everywhere
C. They Are Everywheretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSergei B., the young coach of Pokemo原创 2017-07-28 16:41:57 · 312 阅读 · 0 评论 -
CodeForces - 808C C. Tea Party (贪心)
C. Tea Partytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp invited all his friends to the tea par原创 2017-09-09 20:09:56 · 372 阅读 · 0 评论 -
Code Force 825D Suitable Replacement
D. Suitable Replacementtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings s and t co原创 2017-09-09 20:20:05 · 322 阅读 · 0 评论 -
HDU 5933 ArcSoft's Office Rearrangement 贪心
题目链接:https://vjudge.net/problem/HDU-5933题解:因为拆分合并只需要考虑相邻的区域就好,所以不够就合并,多了就拆分。#include#define maxn 100010#define ll long longusing namespace std;int main(){ int T; scanf("%d",&T); i原创 2017-10-22 19:08:08 · 329 阅读 · 0 评论 -
2018 华中科技校赛 K Walking in the Forest 最大化最小值
链接:https://www.nowcoder.com/acm/contest/106/K来源:牛客网题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of HUST.Now you're going to walk through a large forest. There is a ...原创 2018-04-30 11:25:02 · 324 阅读 · 0 评论 -
HDU 2586 How far a way
勇气小镇是一个有着n个房屋的小镇,为什么把它叫做勇气小镇呢,这个故事就要从勇气小镇成立的那天说起了,修建小镇的时候,为了让小镇有特色,镇长特地只修了n-1条路,并且规定说,所有在勇气小镇的村民,每一次出门必须规划好路线, 路线必须满足在到达终点之前绝对不走回头路。每个人都要这样,不然那个人就不配在小镇生活下去,因为他没有这个勇气。事实上,这并不能算一项挑战,因为n-1条路已经连通了每户原创 2018-01-29 19:47:50 · 393 阅读 · 0 评论 -
CodeForces - 96D Volleyball 最短路
D. Volleyballtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves volleyball very much. One day he原创 2018-01-29 19:33:37 · 612 阅读 · 0 评论 -
51Nod 1119 机器人走方格 组合数模板
机器人走方格V2M*N的方格,一个机器人从左上走到右下,只能向右走或向下走。有多少种不同的走法?由于方法数量可能很大,只需要输出MOD^9+7的结果。第一行,2个数M,N中间用空格隔开。(21000000)输出走法数量Mod 10^9+7#include#define ll long long#define maxn 2000010 #define mod 100000000原创 2018-01-29 19:08:02 · 254 阅读 · 0 评论 -
POJ 1190生日蛋糕
生日蛋糕Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 21221 Accepted: 7546Description7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 R原创 2018-01-29 17:42:51 · 354 阅读 · 0 评论 -
最长上升子序列nlogn的求法
假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5。n下面一步一步试着找出它。我们定义一个序列B,然后令 i = 1 to 9 逐个考察这个序列。此外,我们用一个变量Len来记录现在最长算到多少了首先,把d[1]有序地放到B里,令B[1] = 2,就是说当只有1一个数字2的时候,长度为1的LIS的最小末尾是2。这时Len=1转载 2018-01-20 20:12:12 · 683 阅读 · 0 评论 -
HDU 1556 Color the ball
Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24404 Accepted Submission(s): 11853Problem DescriptionN个气球排成一排,原创 2018-01-24 10:58:43 · 257 阅读 · 0 评论 -
常见的3种博弈总结
巴什博弈典型问题:一堆只有n个物品,两人轮流从堆中取,最少一个,最多m个,最后取光者胜。如果n=m+1。后手胜。取胜法则n=(m+1)*r+s。其中r为任意自然数,s尼姆博弈典型问题:有n堆若干物品,两人轮流从某一堆取任意多物品,规定每次至少取一个,多者不限,最后取光者胜。以三堆为例,我们用(a,b,c)表示某种局势,首先(0,0,0)显然是必败态。第二 种必败态是(0原创 2017-08-07 17:39:45 · 967 阅读 · 0 评论 -
Uva -11624 Fire!
原题链接:https://vjudge.net/problem/UVA-11624双入口同时BFS#include#define INF 10001010using namespace std;char M[1010][1010];int T[1010][1010];bool judgej[1010][1010];bool judgef[1010][1010];int n原创 2018-01-30 17:37:16 · 277 阅读 · 0 评论 -
Uva10047 The Monocycle
原题链接:https://vjudge.net/problem/UVA-10047绞尽脑汁的图论题,虽然只是bfs但是要求到达的最小时间以及符合到达终点的条件还是需要思考一番。用优先队列保证到达时间最小,每一个方块的访问方式由进入的方向以及轮子的颜色划分。#include#define INF 0x3f3f3f3fusing namespace std;int n,m;int原创 2018-01-30 17:32:52 · 343 阅读 · 0 评论 -
CodeForce Round 446 Pride
Pridetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a with length n, you can perform原创 2017-11-18 12:54:16 · 322 阅读 · 0 评论 -
HDU 5245 期望概率
JoyfulTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1610 Accepted Submission(s): 707Problem DescriptionSakura has a very ma原创 2017-11-17 20:34:02 · 326 阅读 · 0 评论 -
HDU 5938 Four Operations 模拟
题目链接:https://vjudge.net/problem/HDU-5938题意:输入一个字符串,从左到右依次插入+-×/,求所得的算式的最大值。题解:算式一定是a+b-c*d/e的形式,c和d只分配一个数,a+b最大的情况只有两种,然后从前向后枚举e的值。#includeusing namespace std;#define ll long longchar s[25];原创 2017-10-22 19:21:17 · 329 阅读 · 0 评论 -
CodeForces - 825E CodeForces - 825E
E. Minimal Labelstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a directed acyclic graph wit原创 2017-08-04 21:29:17 · 631 阅读 · 0 评论 -
CodeForces - 803D Magazine Ad
D. Magazine Adtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe main city magazine offers its readers an原创 2017-08-04 19:37:29 · 376 阅读 · 0 评论 -
CodeForces - 816B Karen and Coffee
B. Karen and Coffeetime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTo stay woke and attentive during cla原创 2017-07-19 17:14:17 · 247 阅读 · 0 评论 -
Gym 100803C — Shopping
题目链接:Shopping题意在一条街上有1-n个店,你一开始在0这个位置,你需要访问每个店,并且最后到n+1这个点然后有m个限制,就给你ci,di表示你去ci这个店之前,你必须先到bi这个点才行保证di>ci问你最小距离走多少贪心 少走回头路,那就走最大闭环 每走一次闭环 这段路就多走两次代码参考:http://www.cnbl原创 2017-07-18 09:16:38 · 277 阅读 · 0 评论 -
KMP next模板
Power StringsTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 47895 Accepted: 19949DescriptionGiven two strings a and b we define a*b to be their conca原创 2017-04-23 20:19:08 · 421 阅读 · 0 评论 -
HDU - 1878 欧拉回路
欧拉回路Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15103 Accepted Submission(s): 5770Problem Description欧拉回路是指不令笔离开纸面,可画过图中每原创 2017-07-22 09:10:23 · 255 阅读 · 0 评论 -
***POJ3255-Roadblocks
RoadblocksTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 14995 Accepted: 5283DescriptionBessie has moved to a small farm and sometimes enjoys returni原创 2017-07-14 20:54:29 · 239 阅读 · 0 评论 -
HDU-1811 Rank of Tetris(拓扑排序)
Rank of TetrisTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9697 Accepted Submission(s): 2798Problem Description自从Lele开发了Ra原创 2017-07-14 14:33:55 · 271 阅读 · 0 评论 -
最长上升子序列
原文章地址:https://xuanwo.org/2015/07/31/dp-lis/。动态规划——最长上升子序列问题介绍最长上升子序列问题,也就是Longest increasing subsequence,缩写为LIS。是指在一个序列中求长度最长的一个上升子序列的问题,是动态规划中一个相当经典问题。在这里我们可以看到,这个上升实质上就是一个对进行定义的过程,所以转载 2017-05-21 12:53:23 · 306 阅读 · 0 评论 -
KMP算法next的变形
设字符串S长度为L此时next表示S的字串T,长度为P的next【P】的值。 void get_valnext(char s[maxn]){ int j=0,k=-1; next[0]=k; while(s[j]!='\0') { if(s[j]==s[k]||k==-1) { ++j;原创 2017-04-25 21:18:59 · 358 阅读 · 0 评论