
个人算法晋升之路
fadedsun
从质疑自己,到坚定梦想.
展开
-
B. Taxi 贪心思想
题目描述: B. Taxi time limit per test3 seconds memory limit per test256 megabytes inputstandard input outp原创 2017-03-28 22:27:55 · 365 阅读 · 0 评论 -
AtCoder - 2271-Lining Up
Problem Statement There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person r原创 2017-08-07 10:10:15 · 896 阅读 · 0 评论 -
hdu 6153 A Secret(最简洁的代码)
A Secret Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others) Total Submission(s): 500 Accepted Submission(s): 199Problem DescriptionToday is the birthday of SF,so原创 2017-08-19 21:32:05 · 1818 阅读 · 3 评论 -
FZU - 1019猫捉老鼠
一只猫和一只老鼠在10*10的迷宫中。迷宫中的每个方格可以是空的,或者含有障碍。猫和老鼠可以进入任意一个空的方格中。当他们相遇时,猫和老鼠在同一个方格中。但是,无论猫或老鼠都不能进入有障碍的方格。我们可以用字符组成的二维数组表示迷宫,如下图所示。老鼠在迷宫中按照一种固定的方式行走:每个时刻,老鼠都向它所面对的方向前进一格,这需要花费1秒时间。如果前方是一个障碍或者是迷宫的边界,它将花1秒的时间按顺时原创 2017-08-22 19:26:55 · 446 阅读 · 0 评论 -
POJ - 3268 Silver Cow Party (俩遍最短路)
题目描述: One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-原创 2017-08-23 10:57:05 · 306 阅读 · 0 评论 -
CodeForces - 750C New Year and Rating(最短代码)
Every Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with ra原创 2017-08-23 14:29:49 · 234 阅读 · 0 评论 -
c++sort函数的用法
# include <cstdio> //c++使用scanf和printf要加的头文件# include <algorithm> //使用sort要加的头文件# include <cstring> //使用字符串比较函数strcmp要加的头文件using namespace std; //c++的命名空间,格式bool cmp(int x,int y) //自己定义的比较函数{原创 2017-12-13 20:02:44 · 1185 阅读 · 0 评论 -
现在流的泪,都是当年犯滴错
没事看一看,铭记于心。数据范围最好开long long,小心爆掉。给出区间(a,b) a可能大于b。原样输出的东东,一定ctrl + C / V取模符号%只能对整数取余,取余要注意不能敲错模数 5.原创 2017-11-07 19:27:37 · 691 阅读 · 0 评论 -
精妙绝伦的脑洞acm题
没事看一看,脑洞大开。持续更新……1.印象最深的一道题是挑战程序设计这本书上看到的关于蚂蚁的那道题。 题目链接: http://poj.org/problem?id=18522.让我痛不欲生的一道题。队里集训,只有我做不出来。感觉智商被碾压。 题目链接: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=127原创 2017-11-08 19:06:56 · 986 阅读 · 0 评论 -
acm中某些较难算法如何学习
1. 首先学习递归,接着是dfs,然后是记忆化搜索,然后就是dp了。2. 然后就是学习RMQ的在线解法,首先要会dp,然后再搞明白类似二进制的倍增思想。3. 主席树,首先要会线段树,然后知道什么是权值线段树,还要明白前缀和的思想。4. 后缀数组,首先要会ST就是倍增加dp的RMQ在线解法,然后懂权值线段树的思想。5.ac自动机要先学会 kmp和字典树未完待续...原创 2018-01-31 17:17:56 · 764 阅读 · 1 评论 -
常用的数论算法板子
常用的数论算法# include <cstdio># include <cstring># include <algorithm># include <queue># include <map># define ll long longusing namespace std;const int maxn = 1e6...原创 2018-05-21 16:36:39 · 414 阅读 · 0 评论 -
胡乱写写
求同时整除两个数的数的和 => 等同于求GCD(X,Y)的约数和原创 2018-10-02 20:52:38 · 133 阅读 · 0 评论 -
数学竞赛中的图论定理
数学竞赛中的图论定理郎塞数当 n >= 6 时, 任意一个 n 阶二色完全图 Kn .总含有单色三角形.原创 2018-09-22 17:20:04 · 1015 阅读 · 0 评论 -
字节跳动春招第一次笔试
字节跳动笔试第一题找零钱,很简单的贪心,每次找最大的就好.第二题字符串处理AAA 三个连在一起的随便去掉一个AABB 去掉第一个B刚开始是把要去掉的标记出来,这里在第一种情况下,不知道要标记哪一个,标记的第一个只过了10%的数据.只好老老实实去写string,用erase删除元素,再从头开始判断,就好.第三题第一眼看上去比较像拓扑排序,然后求每个点最远位置.但是仔细想...原创 2019-03-16 15:48:37 · 698 阅读 · 0 评论 -
链表折叠 面试题
链表面试题我也不知道该叫什么.就叫 链表折叠 吧题目:给一个单链表,形如1 2 3 4 5变成1 5 2 4 3算法复杂度要求为O(n)思路:先把后半部分反转过来,然后把后半部分 和 前半部分 合并.用到的知识点:构建单链表链表反转链表合并(这个其实相当于插入了一个节点)遍历单链表# include <bits/stdc++.h&g...原创 2019-07-30 23:31:01 · 1575 阅读 · 0 评论 -
HDU - 1166 敌兵布阵(新手入门级)
题目描述: C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演原创 2017-08-19 10:00:10 · 275 阅读 · 0 评论 -
HYSBZ - 1008 越狱 (HNOI2008)
题目描述: 监狱有连续编号为1…N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种。如果 相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10^12Output 可能越狱的状态数,模100003取余Sample Input 2 3 Sample Output 6 Hin原创 2017-08-19 08:55:23 · 288 阅读 · 0 评论 -
POJ_3278 Catch That Cow
题目描述: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤原创 2017-07-15 17:44:32 · 261 阅读 · 0 评论 -
最大的位或 HDU - 5969
题目描述: B君和G君聊天的时候想到了如下的问题。 给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大。 其中|表示按位或,即C、 C++、 Java中的|运算。 Input 包含至多10001组测试数据。 第一行有一个正整数,表示数据的组数。 接下来每一行表示一组数据,包含两个整数l,r。 保证 0 <= l <= r <= 10原创 2017-07-21 15:01:54 · 540 阅读 · 0 评论 -
N的阶乘长度log函数的应用
51Nod - 1058题目描述 输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。 Input 输入N(1 <= N <= 10^6) Output 输出N的阶乘的长度 Sample Input 6 Sample Output 3解题思路: 1.使用斯特林公式 n的阶乘长度=0.5*log10(2*PI*n)+n*log10(n/e)+1;(不包含原创 2017-07-19 16:39:12 · 1894 阅读 · 0 评论 -
数塔—动态规划
数塔(dp_基础)在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如上所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗? Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行原创 2017-04-14 11:29:29 · 918 阅读 · 0 评论 -
51Nod - 1786-数据流中的算法 - 众数
题目描述数据流统计功能上线后,为51nod提升用户体验做出了很大的贡献。但是新问题随之而来,夹克老爷还想知道在一个窗口内,访问次数最多用户(即窗口内的众数)。如果有多个众数,取用户ID最小的一个。(窗口的意思是一个固定长度的区间!)(因为数据流是实时的、在线的,所以不允许使用离线算法^_^) Input 第一行为整数n, k。(1 <= n <= 5 * 10^6,1 <= k <= 1000)原创 2017-08-02 17:30:40 · 488 阅读 · 0 评论 -
HDU - 4027 Can you answer these queries? (最全的坑点总结)
题目描述: A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value原创 2017-08-16 21:36:27 · 508 阅读 · 3 评论 -
HDU - 1540 Tunnel Warfare (奇妙的解法)
题目描述: During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Ex原创 2017-08-16 16:57:50 · 801 阅读 · 6 评论 -
hdu6112 今夕何夕
今夕何夕今天是2017年8月6日,农历闰六月十五。小度独自凭栏,望着一轮圆月,发出了“今夕何夕,见此良人”的寂寞感慨。为了排遣郁结,它决定思考一个数学问题:接下来最近的哪一年里的同一个日子,和今天的星期数一样?比如今天是8月6日,星期日。下一个也是星期日的8月6日发生在2023年。小贴士:在公历中,能被4整除但不能被100整除,或能被400整除的年份即为闰年。原创 2017-08-12 20:25:12 · 386 阅读 · 1 评论 -
hdu6108 小C的倍数问题(超简单题)
思路:设数为abc,各位数字和为a+b+c,要让abc和a+b+c同时是x的倍数。问在某一进制下有多少个x。。10进制下。。。1,3,9.所以答案为3.。我试着想了一下可以利用加法和乘法的取模规则化解。。数abc可以写成把a+b+c展开,把乘法也展开就可以看到规律了原创 2017-08-12 15:37:17 · 298 阅读 · 1 评论 -
hdu-2056-Rectangles
RectanglesTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25081 Accepted Submission(s): 8163Problem DescriptionGiven two rectangles and the c原创 2017-08-02 21:38:50 · 465 阅读 · 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-08-08 10:48:42 · 268 阅读 · 0 评论 -
CodeForces - 678D - Iterated Linear Function
题目描述: Consider a linear function f(x) = Ax + B. Let’s define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.Inp原创 2017-07-28 17:19:06 · 338 阅读 · 0 评论 -
(最易理解)51Nod - 1267 ==== 4个数和为0
题目描述: 给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出”Yes”,否则输出”No”。 Input 第1行,1个数N,N为数组的长度(4 <= N <= 1000) 第2 - N + 1行:Aii(-10^9 <= Aii <= 10^9) Output 如果可以选出4个数,使得他们的和为0,则输出”Yes”,否则输出”No”。 Sample Input原创 2017-07-25 21:04:25 · 327 阅读 · 0 评论 -
LightOJ - 1007-Mathematically Hard
题目: Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable.In this problem, you will be given two integers a and b. You have to find the summat原创 2017-08-04 10:31:32 · 292 阅读 · 0 评论 -
简单版堆排序实现
# include <cstdio># include <cstring># include <algorithm>using namespace std;const int maxn = 1e5+10;int n,a[maxn];void init(int n){ for(int i = 1;i <= n;i++) {...原创 2019-08-15 17:28:47 · 133 阅读 · 0 评论