摘要:
最近学了一下最小生成树。。。发发code#include#include#include#includeusing namespace std;const int maxn=1000;struct edge{//定一个结构体来存起点,终点和边权,便于后面的将边权排序; int u,v,w;}a[m... 阅读全文
摘要:
#include#include#include#includeusing namespace std;int mi=99999999999;int xb,yb,xe,ye;const int maxn=51;int a[maxn][maxn],book[maxn][maxn];int move[4... 阅读全文
摘要:
转自大神的详解: http://www.2cto.com/kf/201210/160552.html用划分树来解决选定区间内的第K大值,其实也就两步!一步是建树,另一步则是查询。 先说我对建树的理解吧! 建树的过程很简单:两步就OK了! 第一步:找到序列的中位数,把大于中位数的扔到... 阅读全文
摘要:
//堆排序#include#includeint a[100010],len=0;void insert(int x){ a[++len]=x; int k=len,t; while(k>1 && a[k]a[2*k] && 2*ka[2*k+1] && 2*k+1a[m+1] && m+1#inc... 阅读全文
摘要:
#include #include #define maxn 10005using namespace std;int maxsum[maxn][20], minsum[maxn][20];void RMQ(int num) //预处理->O(nlogn) { int i, j; ... 阅读全文
摘要:
在《啊哈!算法》中看到了这道题,准备敲敲代码。。。题意就是 0可以走,1不能走,输入起点和终点,找到到终点的最小步数。#include#include#include#includeusing namespace std;const int maxn=51;int a[maxn][maxn],boo... 阅读全文
摘要:
#include#include#include#includeusing namespace std;#define ms(k) memset(k,0,sizeof(k))int d[8];int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};//... 阅读全文
摘要:
#include#include#include#includeusing namespace std;struct student{//定义一个结构体,存人名和钱数; string s; int my;}a[12];int main(){ int i,j,k,m,n; sc... 阅读全文
摘要:
/* ID:brodrn1 LANG:c PROG:ride*/#include#include#include#includeusing namespace std;char s[10],a[10];int main(){ int i,j,k,m,n; gets(s); gets(a)... 阅读全文