
====算法====
Newbie006
I am a student.
展开
-
回溯法求解全排列问题(可去除重复排列)
1. 使用标记法求解#include <cstdio>#include <algorithm>using namespace std;int vis[100]; //标记数组,直接判断不需要循环判断,循环见全排列2.cppint re[]= {2,1,2}; //给出数据int ans[100];//下标记录void dfs(int cur,int border)//可以去除重复排列原创 2017-02-26 23:25:41 · 3002 阅读 · 0 评论 -
归并排序以及逆序对统计
归并排序以及逆序对统计1. 归并排序 归并排序利用分治的方法,将两个有序数组进行合并,达到排目的。有序数组可以通过不停地将数组进行二分,最终得到一个数,认为此数组有序。然后将两个一个数的数组进行合并,得到一个有序的有两个数据的数组,然后返回上一层继续合并,最终得到有序数列。原创 2017-01-26 01:26:13 · 557 阅读 · 0 评论 -
快速排序及快速选择问题
快速排序及快速选择问题1. 快速排序 采取分治,通过找到一个中枢值,使得中枢值左边的数小于等于其值,右边大于其值。 递归求解问题 当每一个数被当做一次中枢值,这个数组已经有序原创 2017-01-26 22:23:26 · 705 阅读 · 0 评论 -
高精度加法
#include <stdio.h>#include <string.h>#define MAX 200 //大数最长位数int main(){ char str1[MAX]; char str2[MAX]; char ans[MAX+MAX+1];原创 2017-02-26 23:57:28 · 351 阅读 · 0 评论 -
高精度乘法
#include <stdio.h>#include<string.h>#define MAX 200 //最大位数int main(){ int j,k; int len1,len2,len,flag; int c1[MAX],c2[MAX],ans[MAX+MAX+1];原创 2017-02-26 23:52:38 · 357 阅读 · 0 评论 -
对称子字符串
这个对称子字符串的对称轴不在字符串中,例如QwQ不满足要求,而QWWQ满足```/** *input:roorle *output:4 *input:111 *output:2 */#include <bits/stdc++.h>using namespace std;char str[10];int main(){ scanf("%c",&str[0]);原创 2017-02-28 00:31:00 · 396 阅读 · 0 评论 -
dijkstra算法优先队列
d[i] 是起点到 I 节点的最短距离void Dijkstra(int s) { priority_queue<P, vector<P>, greater<P> > que; fill(d, d + MAXN, INF); d[s] = 0; que.push(make_pair(0, s)); //first:d[i] second:i while (原创 2018-03-24 09:14:59 · 1950 阅读 · 0 评论