2016年5月28日

摘要: define MAXN 100 #define fabs(x) ((x)>0?(x):-(x))#define zero(x) (fabs(x)<1e-10) struct mat{ int n,m; double data[MAXN][MAXN];}; int mul(mat& c,const m 阅读全文
posted @ 2016-05-28 23:27 寡言xy 阅读(146) 评论(0) 推荐(0) 编辑
摘要: //取第k个元素,k=0..n-1//平均复杂度O(n)//注意a[]中的顺序被改变 #define _cp(a,b) ((a)<(b))typedef int elem_t; elem_t kth_element(int n,elem_t* a,int k){ elem_t t,key; int 阅读全文
posted @ 2016-05-28 23:24 寡言xy 阅读(163) 评论(0) 推荐(0) 编辑

2016年5月26日

摘要: #include <cstdio>#include <algorithm> using namespace std; const int maxn = 310;int heavy[maxn];int w,n; int main(){ int s,i,j,boat; scanf("%d",&s); w 阅读全文
posted @ 2016-05-26 23:09 寡言xy 阅读(139) 评论(0) 推荐(0) 编辑

2016年5月23日

摘要: #include <stdio.h>#include <memory.h> int map[100005]; void Adjust(int currentCity) //定义函数(递归){ int priorCity = map[currentCity]; if (priorCity != 0) 阅读全文
posted @ 2016-05-23 22:33 寡言xy 阅读(142) 评论(0) 推荐(0) 编辑

2016年5月20日

摘要: //一、 #include<iostream> #include<cstring> using namespace std; int main(){ int n,ans[22]; memset(ans,0,sizeof(ans));// ans[3]=4;ans[4]=6;ans[7]=12;ans 阅读全文
posted @ 2016-05-20 21:30 寡言xy 阅读(162) 评论(0) 推荐(0) 编辑

2016年5月19日

摘要: #include<stdio.h> #define N 20 int a[N]; int n,k; int dfs(int i, int sum); int main() { int i; scanf("%d%d", &n,&k); for(i=0; i<n; i++){ scanf("%d", & 阅读全文
posted @ 2016-05-19 21:43 寡言xy 阅读(610) 评论(0) 推荐(0) 编辑

2016年5月14日

摘要: #include using namespace std; int f[10000]; int len; void pre() { f[0]=1; for(int i=1;;i++) { f[i]=f[i-1]*2; if(f[i]>1e9) { len=i-1; break; } } } int 阅读全文
posted @ 2016-05-14 15:56 寡言xy 阅读(74) 评论(0) 推荐(0) 编辑

2016年5月9日

摘要: 伪代码: void Knapsack(int n,float M,float v[],float w[],float x[]) { Sort(n,v,w); int i; for (i = 1 ; i <= n ; i++) x[i] = 0; float c=M; for (i=1;i<=n;i+ 阅读全文
posted @ 2016-05-09 23:07 寡言xy 阅读(836) 评论(0) 推荐(0) 编辑
摘要: 从问题的某一初始解出发; while (能朝给定总目标前进一步) { 利用可行的决策,求出可行解的一个解元素; } 由所有解元素组合成问题的一个可行解; 阅读全文
posted @ 2016-05-09 22:55 寡言xy 阅读(666) 评论(0) 推荐(0) 编辑

2016年5月8日

摘要: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int main() { int ncase; char s[110], an 阅读全文
posted @ 2016-05-08 21:48 寡言xy 阅读(171) 评论(0) 推荐(0) 编辑

导航