随笔分类 -  c/c++

摘要:#includeint const N=100000;int main(){ register double sum=0; register int i=0; for(i=0;i!=N;++i) { sum=sum+i; } printf("%lf\... 阅读全文
posted @ 2014-11-08 19:53 剑风云 阅读(3155) 评论(0) 推荐(0)
摘要:#define LOCAL#include#include#includeusing namespace std;typedef char DataType;typedef struct Node{ DataType data; struct Node *LChild; struc... 阅读全文
posted @ 2014-10-25 19:51 剑风云 阅读(179) 评论(0) 推荐(0)
摘要:#define LOCAL#include#include#includeusing namespace std;typedef int ElemType;const int maxSize=10;//传入函数的一维数组经过函数之后数组元素发生变化 int REV(int *a,int x,int ... 阅读全文
posted @ 2014-10-08 16:07 剑风云 阅读(290) 评论(0) 推荐(0)
摘要:#define LOCAL#include#include#includeusing namespace std;typedef int ElemType;typedef struct Node{ ElemType data; struct Node *next;}Node,*LinkL... 阅读全文
posted @ 2014-10-08 15:45 剑风云 阅读(357) 评论(0) 推荐(0)
摘要:#define LOCAL#include#includeusing namespace std;typedef int ElemType;void fun1(ElemType *x){ cout>a; cout<<(*&a)<<endl; fun1(&a); b=&a; ... 阅读全文
posted @ 2014-10-08 13:46 剑风云 阅读(155) 评论(0) 推荐(0)
摘要:#define LOCAL#include #include #include #define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define ElemType int#define MAXSIZE 100 /*此处的... 阅读全文
posted @ 2014-09-30 16:21 剑风云 阅读(363) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;queue Q;int temp;void tringle(const int n){ Q.push(1); for(int i=2;i<=n;i++) { Q.p... 阅读全文
posted @ 2014-08-01 15:38 剑风云 阅读(1450) 评论(0) 推荐(0)
摘要:#define LOCAL#include#include#includeusing namespace std;int main(){#ifdef LOCAL freopen("sscanf.in","r",stdin); freopen("sscanf.out","w",stdout... 阅读全文
posted @ 2014-05-26 09:30 剑风云 阅读(174) 评论(0) 推荐(0)
摘要:#define LOCAL#include#includeconst int MAX_N=100;int a[MAX_N],b[MAX_N];void init(){ for(int i=0;i=1) { if(b[sum-1]<10) printf(... 阅读全文
posted @ 2014-05-20 18:15 剑风云 阅读(283) 评论(0) 推荐(0)
摘要:devcpp增加对c++11的支持工具→编译选项如图,增加c++11支持c++11 random头文件对随机数的支持// random_device example#include #include int main (){ std::random_device rd; std::cout #i... 阅读全文
posted @ 2014-05-19 11:39 剑风云 阅读(278) 评论(0) 推荐(0)
摘要:归并排序#define LOCAL#include#include //生成随机数c++11支持 #include #include #includeusing namespace std;int const MAX_N=10;int a[MAX_N],b[MAX_N],c[2*MAX_N];//归... 阅读全文
posted @ 2014-05-19 11:33 剑风云 阅读(180) 评论(0) 推荐(0)
摘要://#define LOCAL#include#include#include#includeint const MAX_N=101;typedef struct Point{ int x,y; bool operatorVec[i].y) { ... 阅读全文
posted @ 2014-05-18 10:31 剑风云 阅读(197) 评论(0) 推荐(0)
摘要://#define LOCAL#include#includeusing namespace std;int const MAX_N=100001;int const INF=10000000;int N,M,x[MAX_N];void init(){ for(int i=0;i1) {... 阅读全文
posted @ 2014-05-18 10:06 剑风云 阅读(268) 评论(0) 推荐(0)
摘要:int const MAX_N=100000;int par[MAX_N];//父亲int rank[MAX_N];//树的高度//初始化n个元素void init(int n){ for(int i=0;i#includeint const MAX_N=100000;int const MA... 阅读全文
posted @ 2014-05-17 10:30 剑风云 阅读(136) 评论(0) 推荐(0)
摘要://#define LOCAL#include#includeusing namespace std;int const MAX_N=10005;int const MAX_M=100;int const INF=100000000;int N,M,x[MAX_N],lb,ub;//判断是否满足条件... 阅读全文
posted @ 2014-05-16 17:25 剑风云 阅读(318) 评论(0) 推荐(0)
摘要:条件C(x):=可以选择是单位重量的价值不小于x,则该问题就变成了满足C(x)的最大的x,那么怎么判断C(x)是否可行呢?假设我们选了某个物品的集合S,那么它们的单位重量价值是:因此就变成了判断是否存在s满足下面条件:把这个不等是进行变形就得到//#define LOCAL#include//#in... 阅读全文
posted @ 2014-05-16 08:49 剑风云 阅读(275) 评论(0) 推荐(0)
摘要://#define LOCAL#include#include#include#includeint const MAX_N=1001;typedef struct Point{ double x,y; bool operatorVec[i].y) { ... 阅读全文
posted @ 2014-05-15 09:40 剑风云 阅读(279) 评论(0) 推荐(0)
摘要:为了照到点Point(x0,y0),圆心可以在一个范围内移动,我们设该范围为(x,y)(Vec[i].x,Vec[i].y)表示第如果圆心在这个范围内,则第i个点就一定能照到,sum表示为了能照到前i个点,最靠近右边的圆的边界坐标。#define LOCAL#include#include#incl... 阅读全文
posted @ 2014-05-15 09:23 剑风云 阅读(306) 评论(0) 推荐(0)
摘要://#define LOCAL#include#includeint const MAX_N=10001;int N,T;std::pair P[MAX_N];void solve(){ char c_now='#',c_next; int i=0,sum=0; while(tru... 阅读全文
posted @ 2014-05-13 16:57 剑风云 阅读(142) 评论(0) 推荐(0)
摘要:观察可以发现,0,1,2,……,n结尾的分组中,maxsum a[0] = a[0]maxsum a[1] = max( a[0] + a[1] ,a[1]) = max( maxsum a[0] + a[1] ,a[1])maxsum a[2] = max( max ( a[0] + a[1] +... 阅读全文
posted @ 2014-05-13 15:50 剑风云 阅读(342) 评论(0) 推荐(0)