随笔分类 - 模板
矩阵快速幂 模板
摘要:Recursive sequence Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u HDU 5950 Description Farmer John likes to play mathematics gam
阅读全文
SPFA 模板
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 #define inf 0x3f3f3f3f 11 struct A 12 { 13 int ed; 14 int po...
阅读全文
单链表
摘要:#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct List{ int date; List *next;};void creat(List *head) //往头指针后加,倒序{ List
阅读全文
欧拉函数(模板)
摘要:#include #include using namespace std;int oula(int n){ int ans=n; int i; for(i=2;i1) ans=ans/n*(n-1); return ans;}i...
阅读全文
三种存图方式(邻接矩阵,邻接表,链式前向星)
摘要:#include#include#include#include#include using namespace std;const int MAXN=10;struct node{ int to,cost;};int a[MAXN][MAXN];vector ...
阅读全文
最小树形图(朱刘算法)(poj 3164)
摘要:题目链接 ommand NetworkTime Limit: 1000MS Memory L...
阅读全文
二分and三分
摘要:部分转载自: https://www.cnblogs.com/whywhy/p/4886641.html二分:二分,顾名思义,就是把一个分成两个,呃,先来一个例子,现在有一个递增序列 a(1),a(2) ......a(n),让你查找x在不在这个序列里面,在的话...
阅读全文
数位dp讲解(转)
摘要:转载自:传送门数位DP其实是很灵活的,所以一定不要奢求一篇文章就会遍所有数位DP的题,这一篇只能是讲清楚一种情况,其他情况遇到再总结,在不断总结中慢慢体会这个思想,以后说不定就能达到一看到题目就能灵活运用的水平。(其实DP都是这样……)这一篇要说的数位DP是一道最简单...
阅读全文
POJ1330-LCA最近公共祖先(Tarjan算法模板代码)
摘要:转自:https://blog.csdn.net/Akatsuki__Itachi/article/details/81279173题目链接 poj1330关于LCA的Tarjan算法详解可看https://blog.csdn.net/Septembre_/ar...
阅读全文
Color the ball (树状数组,改段求点)
摘要:N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a #include#includeusing namespace std;int c[100100];int a[100100];int n;int lowbit(int x){ ...
阅读全文
A Simple Problem with Integers(树状数组,改段求段)
摘要:A Simple Problem with IntegersYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of...
阅读全文
树状数组(逆序对)(模板)
摘要:举个例子加以说明: 例子来源 假设给定的序列为 4 3 2 1,我们从左往右依次将给定的序列输入,每次输入一个数temp时,就将当前序列中大于temp的元素的个数计算出来,并累加到ans中,最后ans就是这个序列的逆序数个数。 序列的变化(下划线为新增加元...
阅读全文
BFS和DFS模板
摘要:BFS#include #include #include #include #include #include #include struct A{ int x,y,time;}t,now;int map1[350][350];int m,n;int vis[...
阅读全文
高斯消元详解+模板
摘要:大佬讲解: https://blog.csdn.net/pengwill97/article/details/77200372 大佬模板: https://blog.csdn.net/pengwill97/article/details/77282328 ...
阅读全文
set用法详解
摘要:1.关于setC++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构操作。vector封装数组,list封装了链表,map和set封装了二...
阅读全文
map用法详解
摘要:迭代器用法map m; //第一个为键,第二个为值 for(int i=10;i>=0;i--) // 这里是按从大到小的顺序,但是迭代器是按从小到大的顺序输出 if(i%2==0) //因为map自带按键从小到大...
阅读全文
LIS LCS (最长上升子序列,最长公共子序列)
摘要:LIS 最长上升子序列 #include #include using namespace std;int a[1001],ans[1001],len;int main(){ int n,T; cin>>T; while(T--) { ...
阅读全文
去重,lower_bound(),upper_bound()
摘要:bool cmp(int a,int b){ return a<b;}int main(){ int a[10]={2,7,1,4,4,6}; sort(a,a+6,cmp); // 去重之前先排序 int m=unique(a,...
阅读全文
浙公网安备 33010602011771号