
模板
文章平均质量分 65
icodeajk
小菜鸟路过
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
bfs模板
bfs模板:#include#include#include#include#include#includeusing namespace std;#define N 1000+5int map[N][N];bool visit[N][N]; //标记访问int n, m;int dx[4]={1, 0, -1, 0};int dy[4]={0, 1, 0, -1原创 2016-03-26 23:04:18 · 319 阅读 · 0 评论 -
并查集模板
自己习惯这么写, 复习用:#include#include#include#include#includeusing namespace std;#define N 1005int fa[N];void init(int n){ for(int i=0; i<n; i++){ fa[i]=i; }}int find(int u){原创 2016-03-22 22:46:20 · 288 阅读 · 0 评论 -
神奇的进制转换(模板)
(10进制转换为其他进制):#includeint main(){ int m,n; char a[100]; while(~scanf("%d%d",&n,&m)) { int i, t=1; if(n<0) {n=-n;t=0;} for( i=0;n!=0;i++) {原创 2016-04-08 13:09:16 · 414 阅读 · 0 评论 -
dfs模板
直接上模板吧,自己复习用:#include#include#include#incldueusing namespace std;#define N 10000+5char map[N][N];bool visit[N][N];int cnt=0;int n, m;int dx[4]={1, 0, -1, 0};int dy[4]={0, 1, 0, -1};int d原创 2016-03-31 22:09:22 · 478 阅读 · 0 评论 -
归并排序求逆序对
求逆序对方法有两种:树状数组和归并排序,还有暴力暴力就是两个for循环判断当ia[j],则ans++;这里先说归并排序吧,在另一篇博客中再讲树状数组求逆序对(实际上是我写树状数组的还有bug没找到.......)#include#include#include#includeusing namespace std;const int N = 100005;int a[N原创 2016-04-14 12:54:23 · 323 阅读 · 0 评论 -
kmp模板
我的习惯写法, 自己复习用:#include#include#define N 1005char a[N], b[N];int d1, d2;int next[N];void Get_next(){ int i, j; i=1, j=0; next[1]=0; while(j<d2){ if(j==0||b[i]==b[j]){原创 2016-03-22 22:25:26 · 334 阅读 · 0 评论 -
最小公倍数公约数(gcd函数)(模板)
hrbust 1882链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1882三原色Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 783(298 users)原创 2016-04-08 12:59:35 · 1304 阅读 · 0 评论 -
快速幂
Rightmost Digit问题描述 :Given a positive integer N, you should output the most right digit of N^N.输入:The input contains several test cases. The first line of the input is a single integ转载 2016-04-16 22:05:07 · 442 阅读 · 0 评论