自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 数码游戏

2019-08-17 10:25:58 198

原创 同余

线性运算:如果a≡b(mod m),c≡d(mod m),那么a ± c≡b ± d(mod m),且a *c≡b*d(mod m)除法:若ac≡bc(mod m) c≠0则 a≡b(mod m/gcd(c,m)) 其中gcd(c,m)表示c,m的最大公约数。特殊地,gcd(c,m)=1 则a≡b(mod m)幂运算:如果a≡b(mod m),那么a^n≡b^n(mod m)若a≡b(mod...

2019-08-16 23:28:45 162

原创 exBM任意模数

https://ac.nowcoder.com/acm/contest/889/A#include<bits/stdc++.h>using namespace std;const int N = 1e5 + 5;const int mod = 1e9;typedef long long ll;int n, m;// given first m items i...

2019-08-15 22:24:44 301

转载 杜教BM

#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <string>#include <map>#include <set>#include &...

2019-07-26 19:40:43 110

原创 数组模拟双向链表

http://codeforces.com/contest/1154/problem/E#include<bits/stdc++.h>using namespace std;const int N = 3e5+5;int n, k;int l[N], r[N], vis[N], a[N], id[N]; //数组模拟双向链表 int main(){ cin.tie(...

2019-04-23 16:10:10 719

原创 spfa

http://acm.hdu.edu.cn/showproblem.php?pid=3790链式前向星 不用判重边,dijkstra要判重边#include<bits/stdc++.h>#define INF 1<<30using namespace std;int n,m,cnt;const int N=1005;int vis[N],dis[N],h...

2019-04-06 11:05:18 75

转载 强连通

https://blog.csdn.net/justlovetao/article/details/6673602二、Tarjan算法(有向图的缩点)1、内容:Tarjan算法是基于对图深度优先搜索的算法,每个强连通分量为搜索树中的一棵子树。搜索时,把当前搜索树中未处理的节点加入一个堆栈,回溯时可以判断栈顶到栈中的节点是否为一个强连通分量。2、主要过程:(1)每个点都有两个参数:D...

2019-04-05 14:15:02 176

原创 dijkstra 优先队列+前向星

https://vjudge.net/problem/UVA-12661题意:给你有向图,每条边呈周期性开放,即开放a时间,再关闭b时间,再开放a时间以此类推如果时间不足以穿过这条路则不能走,你可以在节点等待时间,问从s走到t所需要的最小时间需要注意的地方:1.如果开放时间小于边的长度,这条边是无论怎样都不能通过的,所以一开始就不能把这条边添加进去2.如果到达某一点时,这条边是...

2019-04-05 10:25:18 125

原创 POJ-3233-Matrix Power Series-两次二分

http://poj.org/problem?id=3233POJ3233  题目大意:给定矩阵A,求A + A^2 + A^3 + ... + A^k的结果(两个矩阵相加就是对应位置分别相加)。输出的数据mod m。k<=10^9。  这道题两次二分,相当经典。首先我们知道,A^i可以二分求出。然后我们需要对整个题目的数据规模k进行二分。比如,当k=6时,有:  A + A...

2019-04-03 22:16:21 109

原创 最小生成树 kruskal

#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int n,m,tot=0,k=0;//n端点总数,m边数,tot记录最终答案,k已经连接了多少边 int fat[200010];//记录集体老大 struct node{ int from,...

2019-03-25 23:34:43 84

原创 最小生成树 prim

https://www.luogu.org/problemnew/show/P1111#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;int a[1005][1005];int lowc[1005],vis[1005];int main(){ int n,k;cin>&gt...

2019-03-25 23:09:04 103

原创 hdu 2647 Reward (拓扑排序)

http://acm.hdu.edu.cn/showproblem.php?pid=2647如果队列能弹出的不够n那么就是-1;#include<bits/stdc++.h>using namespace std;typedef long long ll;int n,m;vector<int>e[20005];queue<int>q;int...

2019-03-25 19:24:23 128

原创 快排求第k大数

#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<queue>#include<vector>#define INF 0x3f3f3f3ftypedef long long ll;using names...

2019-03-21 13:44:42 401

原创 归并排序(求逆序数)

#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<queue>#include<vector>#define INF 0x3f3f3f3ftypedef long long ll;using names...

2019-03-21 13:20:32 220

原创 分而治之

https://pintia.cn/problem-sets/1101463301088948224/problems/1101463872210546688分而治之,各个击破是兵家常用的策略之一。在战争中,我们希望首先攻下敌方的部分城市,使其剩余的城市变成孤立无援,然后再分头各个击破。为此参谋部提供了若干打击方案。本题就请你编写程序,判断每个方案的可行性。输入格式:输入在第一行给出两...

2019-03-04 11:46:20 153

原创 阅览室(模拟)

https://pintia.cn/problem-sets/1101463301088948224/problems/1101463872202158080天梯图书阅览室请你编写一个简单的图书借阅统计程序。当读者借书时,管理员输入书号并按下S键,程序开始计时;当读者还书时,管理员输入书号并按下E键,程序结束计时。书号为不超过1000的正整数。当管理员将0作为书号输入时,表示一天工作结束,你的...

2019-03-04 11:39:46 222

原创 小字辈(bfs)

https://pintia.cn/problem-sets/1101463301088948224/problems/1101463872214740992本题给定一个庞大家族的家谱,要请你给出最小一辈的名单。输入格式:输入在第一行给出家族人口总数 N(不超过 100 000 的正整数) —— 简单起见,我们把家族成员从 1 到 N 编号。随后第二行给出 N 个编号,其中第 i 个编...

2019-03-04 11:25:31 370

原创 喊山(bfs)

https://pintia.cn/problem-sets/1101463301088948224/problems/1101463872189575168一个山头呼喊的声音可以被临近的山头同时听到。题目假设每个山头最多有两个能听到它的临近山头。给定任意一个发出原始信号的山头,本题请你找出这个信号最远能传达到的地方。输入格式:输入第一行给出3个正整数n、m和k,其中n(≤10000)...

2019-03-04 11:17:07 293

转载 链式前向星

转载自:https://blog.csdn.net/m0_37389559/article/details/75200652我们首先来看一下什么是前向星. 前向星是一种特殊的边集数组,我们把边集数组中的每一条边按照起点从小到大排序,如果起点相同就按照终点从小到大排序,并记录下以某个点为起点的所有边在数组中的起始位置和存储长度,那么前向星就构造好了. 用len[i]来记录所有...

2019-02-25 12:21:30 115

原创 A - Invitation Cards(spfa)

https://vjudge.net/contest/280753#problem/AIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate thea...

2019-02-24 21:14:38 148

原创 M - 畅通工程续 (dikjstra)

https://vjudge.net/contest/280753#problem/M某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处...

2019-02-24 14:20:36 132

原创 G - Sliding Window (单调队列)

https://vjudge.net/contest/283317#problem/GAn array of size n ≤ 10 6 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can o...

2019-02-23 21:13:39 364

原创 Largest Rectangle in a Histogram(单调栈)

A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows ...

2019-02-23 08:56:14 118

原创 C. Team Tic Tac Toe(简单暴力)

http://codeforces.com/group/NVaJtLaLjS/contest/238202/problem/CC. Team Tic Tac Toetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outpu...

2019-02-22 09:10:20 256

原创 E. Family Tree(最近公共祖先)

http://codeforces.com/group/NVaJtLaLjS/contest/238202/problem/EE. Family Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFa...

2019-02-22 09:05:12 242

原创 C. Rest Stops

http://codeforces.com/group/NVaJtLaLjS/contest/238204/problem/CC. Rest Stopstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFar...

2019-02-19 10:48:36 201

原创 B. Hoofball(dfs)

http://codeforces.com/group/NVaJtLaLjS/contest/238204/problem/BB. Hoofballtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn p...

2019-02-19 10:37:21 167

原创 A. Taming the Herd

http://codeforces.com/group/NVaJtLaLjS/contest/238204/problem/AA. Taming the Herdtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output...

2019-02-18 19:52:37 136

原创 G - Co-prime(分解质因子+容斥定理)

https://vjudge.net/contest/280477#problem/GGiven a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-...

2019-02-18 12:55:14 194

原创 F - 硬币(dp)

https://vjudge.net/contest/279505#problem/F给出硬币面额及每种硬币的个数,求从1到m能凑出面额的个数。 Input多组数据,每组数据前两个数字为n,m。n表示硬币种类数,m为最大面额,之后前n个数为每种硬币的面额,后n个数为相应每种硬币的个数。 (n&lt;=100,m&lt;=100000,面额&lt;=100000,每种个数&lt;=100...

2019-02-18 09:02:07 222

原创 E - 划分(dp,二进制拆分)

https://vjudge.net/contest/279505#problem/E现有面值为1、2、3、4、5、6的硬币若干枚,现在需要知道能不能将这些硬币分成等额的两堆。 Input每行输入6个正整数,分别表是面值为1、2、3、4、5、6的硬币的个数,若输入6个0代表输入结束。单种硬币的数量不会超过20000。Output若能分割,输出 ``Can be divided....

2019-02-18 08:40:11 352

原创 C - Unidirectional TSP (dp)

https://vjudge.net/contest/279505#problem/C题目大意:给一个n*m的矩阵 数字代表值,有三个方向移动,向右,右上,右下。可以从n行到第1行,也可以从第1行到第n行。求从第一列到最后一列所经过路程值的和,并打印路径(行数),要求字典序最小。题目分析:因为要求字典序最小,正推不好记录路径。所以采用逆推。dp【i】【j】表示:第i行第j列得最...

2019-02-17 20:50:06 114

原创 K - bfs

https://vjudge.net/contest/279018#problem/KYou play a new RPG. The world map in it is represented by a grid of n × m cells. Any playing character staying in some cell can move from this cell in four...

2019-02-17 17:18:18 202

原创 E - 三分

https://vjudge.net/contest/279018#problem/EJosephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which has ...

2019-02-17 16:34:13 106

原创 I. Convention II(优先队列)

http://codeforces.com/group/NVaJtLaLjS/contest/238203/problem/II. Convention IItime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output...

2019-02-17 16:02:32 188

原创 G. Back and Forth(dfs)

http://codeforces.com/group/NVaJtLaLjS/contest/238203/problem/GG. Back and Forthtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFarmer John h...

2019-02-17 15:43:27 147

原创 E. Convention(二分)

http://codeforces.com/group/NVaJtLaLjS/contest/238203/problem/EE. Conventiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCow...

2019-02-17 15:31:10 141

原创 C. Mooyo Mooyo(dfs)

题目链接题目大意:给你n,k n为行数 列数为10,矩阵中有0~9的数字,0代表无,k为消去相同数字的最小个数。若一个数的的上下左右有一个数与它相同,则它们是连通的。连通数若&gt;=k,则可以将连通数字变为0;消去后,由于重力非0数字下落。空位用0代替。下落后可能会产生新的连通块,继续消去,在模拟重力下落。直至无连通块。输出模拟后的图。题目分析:求连通块用dfs ,再...

2019-02-17 14:34:06 165

原创 B. Teamwork(dp)

题目链接B. Teamworktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor his favorite holiday, Farmer John wants to send presents to ...

2019-02-17 14:31:34 109

原创 A. The Bucket List

题目链接A. The Bucket Listtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFarmer John is considering a change in how he allocates b...

2019-02-17 14:07:24 249

空空如也

空空如也

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

TA关注的人

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