08 2014 档案

摘要:4 61 42 63 122 7// poj 3624 标准的01背包 优化的一位数组#include #include using namespace std;int w[3500],v[3500],dp[13000];int main (){ int n,m,i,j; scanf("%d%d",... 阅读全文
posted @ 2014-08-18 18:51 2014acm 阅读(311) 评论(0) 推荐(0) 编辑
摘要:物品 1 2 3 4 5 6价值 1 2 3 4 5 6个数4 7459 101234567891011121314151617181920212223242526272810000000000000000000000000000dp[0] = 1;物品种类 i= 10123456789101112... 阅读全文
posted @ 2014-08-18 11:23 2014acm 阅读(174) 评论(0) 推荐(0) 编辑
摘要:#include #include int dp[60001];void f(int maxv,int n,int c[ ],int v[ ])//最大可能价值、 物品种类、物品数量、物品价值 { int i,j,k,t; memset(dp,0,sizeof(dp)); dp[0] = 1; fo... 阅读全文
posted @ 2014-08-18 11:09 2014acm 阅读(151) 评论(0) 推荐(0) 编辑
摘要:#include #include int dp[60001];void f(int maxv,int n,int c[ ],int v[ ]) //最大可能价值、 物品种类、物品数量、物品价值 { int i,j,k,t; memset(dp,0,sizeof(dp)); dp[0] = 1; f... 阅读全文
posted @ 2014-08-18 10:56 2014acm 阅读(163) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int cash, n, m[13], d[13];int f[100100];int money, i, v, temp, k;int solve() { memset(f, 0, sizeof(f)); ... 阅读全文
posted @ 2014-08-18 10:20 2014acm 阅读(229) 评论(0) 推荐(0) 编辑
摘要:// 多重背包 DP/* 题目大意是:给定N种面值分别为d[i]的钞票,数量分别为n[i]张.再给一个整数cash.求,用这些钞票能表示出的不大于cash的最大值是多少.数据范围N#include const int MAXN = 100001;const int MAXM = 110;int n,... 阅读全文
posted @ 2014-08-18 10:13 2014acm 阅读(219) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[1005], w,v,T,M;int max(int x,int y){ return x>y?x:y; }void f( ){ int i,j; for (i=1; i>w>>v; //直接读进去 for (... 阅读全文
posted @ 2014-08-18 09:57 2014acm 阅读(191) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[1005], w[105],v[105],T,M;int max(int x,int y){ return x>y?x:y; }void f( ){ int i,j; for (i=1; i=w[i]; j--... 阅读全文
posted @ 2014-08-18 09:56 2014acm 阅读(114) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[1005], w[105],v[105],T,M;int max(int x,int y){ return x>y?x:y; }void f( ){ int i,j; for (i=1; i=0; j-... 阅读全文
posted @ 2014-08-18 08:34 2014acm 阅读(157) 评论(0) 推荐(0) 编辑
摘要:#include #define MAX 200int main( ){ int n,i,j,a[MAX][MAX]={0}; scanf("%d",&n); for ( i=0; i#define MAX 200int main( ){ int m,n,i,j,a[MAX][MAX]={0}; s... 阅读全文
posted @ 2014-08-17 15:30 2014acm 阅读(108) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;#define MAX 200int dp[MAX][MAX];int f(int M,int N){ if(M>m>>n) { f(m,n); coutusing namespace std;#def... 阅读全文
posted @ 2014-08-17 13:13 2014acm 阅读(93) 评论(0) 推荐(0) 编辑
摘要:递归#include using namespace std;int f(int a,int b){if(a>m>>n)cout using namespace std;int f(int a,int b) { if(b==0) return 1 ; if(a>m>>n) cout<<f(m,n)... 阅读全文
posted @ 2014-08-17 11:26 2014acm 阅读(238) 评论(0) 推荐(0) 编辑
摘要:// poj 1458 zoj 1733 最长公共子序列 DP #include #include #define N 1005using namespace std ;char s1[N],s2[N]; int dp[N][N];int max(int a,int b) { return a>b ... 阅读全文
posted @ 2014-08-17 11:10 2014acm 阅读(115) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;#include#define N 1005char s1[N],s2[N];int dp[N][N];int max(int a,int b) { return a>b ? a:b ;}int f(int x ,int y){if(dp[x... 阅读全文
posted @ 2014-08-17 10:48 2014acm 阅读(133) 评论(0) 推荐(0) 编辑
摘要:选择排序,就是从一列未排序的数组中先选出最小(最大)的数,放在数组的第一位,第一位原来的数字放在最小的原来的位置,再选出第二小的数,放在数组的第二位,第二位原来的数字放在第二小原来的位置~~~~这样说有些绕了哈,简单描述就是每次发现一个最小的、第二小的都让他们分别和第一位的、第二位的数字换位。如此,... 阅读全文
posted @ 2014-08-16 13:28 2014acm 阅读(121) 评论(0) 推荐(0) 编辑
摘要:插入排序的基本思想是:对于数组前边部分已经是排好序的了,对于接下来的元素查找其在前面的位置,插入之。如下图中1 2 4 7 已经排好序,接下来找到2的位置,插入到1和3之间。之后同样处理4和9.参考程序(C语言实现)如下:#includevoid Insection_Sort(int *A, in... 阅读全文
posted @ 2014-08-16 13:01 2014acm 阅读(229) 评论(0) 推荐(0) 编辑
摘要:算法描述:1.从第一个元素开始,该元素可以认为已经被排序;(j=0的那个元素)2.取出下一个元素,在已经排序的元素序列中从后向前扫描;10, 5, 2, 4, 75, 10, 2, 4, 72, 5, 10, 4, 72, 4, 5, 10, 72, 4, 5, 7, 103.如果元素(已排序)大于... 阅读全文
posted @ 2014-08-16 12:30 2014acm 阅读(123) 评论(0) 推荐(0) 编辑
摘要:#include void bubble_sort(int a[],int n)//n为数组a的元素个数 { int i,j,temp; for(j=0;ja[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; ... 阅读全文
posted @ 2014-08-16 10:49 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:#include void bubble_sort(int a[],int n)//n为数组a的元素个数 { int i,j,temp; for(j=0;ja[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; ... 阅读全文
posted @ 2014-08-16 10:31 2014acm 阅读(154) 评论(0) 推荐(0) 编辑
摘要:for(i=1;i=i;j--) s 执行n-1次 当 i=2时,for(j=n;j>=i;j--) s 执行n-2次 ............. 当i=n-1时,for(j=n;j>=i;j--) s 执行1次 共执行 1+ 2+3+....+n-1=n*n/2次for(j=n;j>=i;j--... 阅读全文
posted @ 2014-08-15 13:09 2014acm 阅读(5272) 评论(0) 推荐(0) 编辑
摘要:for(j=1;j=0;i--) { b[j]=a[i]; j++; }数组a复制给b数组a有n个元素,数组b也是; 数组a中存放了n个数据; 程序前面需要将变量j赋初值0; 程序作用是将a中的数据按照倒序存放到数组b中,即b[0]=a[n-1]; b[1]=a[n-2]; ...; ... 阅读全文
posted @ 2014-08-15 13:08 2014acm 阅读(634) 评论(0) 推荐(0) 编辑
摘要:// 源程序2 DP#include int n,ans, a[1001],b[1001];int main(){ int i,j; scanf("%d",&n); for(i=1;ia[j]&&b[j]+1>b[i]) b[i]=b[j]+1; ans=1; for(i=1;i<=n;i++) i... 阅读全文
posted @ 2014-08-15 11:30 2014acm 阅读(82) 评论(0) 推荐(0) 编辑
摘要:#include #includeusing namespace std;struct node{ int l,w;}dp[1005];int g[1005][1005];int d[1005];int n,max_v;int f(int i){ if (d[i]>0) return d[i]; d... 阅读全文
posted @ 2014-08-15 11:23 2014acm 阅读(107) 评论(0) 推荐(0) 编辑
摘要:#include#include#include#includeusing namespace std;struct p{int a,b;};bool cmp(p p1, p p2){if(p1.b>p2.b) return true;if(p1.b==p2.b && p1.a>m;while(m-... 阅读全文
posted @ 2014-08-15 11:22 2014acm 阅读(99) 评论(0) 推荐(0) 编辑
摘要:公约数和公倍数时间限制:1000ms | 内存限制:65535KB难度:1描述小明被一个问题给难住了,现在需要你帮帮忙。问题是:给出两个正整数,求出它们的最大公约数和最小公倍数。输入第一行输入一个整数n(0 int gcd(int m,int n) { if(n==0) return m;... 阅读全文
posted @ 2014-08-13 22:42 2014acm 阅读(137) 评论(0) 推荐(0) 编辑
摘要:总提交:1728 测试通过:649描述输入两个正整数m和n(1int gcd(int m,int n){ if(n==0) return m; else return gcd(n,m%n);}int main(){ int x,y,t; while(scanf("%... 阅读全文
posted @ 2014-08-13 22:33 2014acm 阅读(442) 评论(0) 推荐(0) 编辑
摘要:#includeusing namespace std;struct point{ int x,y;};int main(){ point p,q; cin>>p.x>>p.y>>q.x>>q.y; cout<<p.x*q.y+p.y*q.x<<endl;} 阅读全文
posted @ 2014-08-13 21:50 2014acm 阅读(117) 评论(0) 推荐(0) 编辑
摘要:三点顺序时间限制:1000ms | 内存限制:65535KB难度:3描述现在给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,现在让你判断A,B,C是顺时针给出的还是逆时针给出的?如:图1:顺时针给出图2:逆时针给出 输入每行是一组测试数据,有6个整数x1,y1,... 阅读全文
posted @ 2014-08-13 21:43 2014acm 阅读(154) 评论(0) 推荐(0) 编辑
摘要:三角形面积时间限制:3000 ms | 内存限制:65535 KB 难度:2描述 给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积输入每行是一组测试数据,有6个整数x1,y1,x2,y2,x3,y3分别表示三个点的横纵坐标。(坐标值都在0到10000之间)输入0 0 0 0 ... 阅读全文
posted @ 2014-08-13 21:42 2014acm 阅读(140) 评论(0) 推荐(0) 编辑
摘要:C++:重载函数2(计算面积)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:370 测试通过:241描述定义重载函数area(),分别计算正方形、长方形和三角形的面积。输入共计有3行。第1行有一个实数,为正方... 阅读全文
posted @ 2014-08-13 21:40 2014acm 阅读(270) 评论(0) 推荐(0) 编辑
摘要:C++:友元1(两点之间的距离)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:674 测试通过:457描述定义一个二维平面中的点(point)类,类中的数据成员为点的坐标,然后定义友元函数dist()用来计算... 阅读全文
posted @ 2014-08-13 21:38 2014acm 阅读(276) 评论(0) 推荐(0) 编辑
摘要:C++:类与对象5(矩形的面积与周长)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:349 测试通过:235描述 定义并测试一个类名为rectangle的矩形类,数据成员为矩形的长和宽,定义2个成员函数分... 阅读全文
posted @ 2014-08-13 21:36 2014acm 阅读(275) 评论(0) 推荐(0) 编辑
摘要:C++:类与对象4(对象成员:点与矩形)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:467 测试通过:290描述 定义点类,再定义矩形类,矩形包含2个点,分别表示对角顶点。输入2个顶点的坐标,计算矩形... 阅读全文
posted @ 2014-08-13 21:35 2014acm 阅读(316) 评论(0) 推荐(0) 编辑
摘要:C++:类与对象2(圆的周长和面积)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:1038 测试通过:524描述使用类编写程序,输入以后圆的半径,计算并显示圆的周长和面积。圆周率取:3.14输入 输入包含n组... 阅读全文
posted @ 2014-08-13 21:33 2014acm 阅读(270) 评论(0) 推荐(0) 编辑
摘要:C语言实验一(顺序):题目2、圆柱体体积时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:494 测试通过:196描述 请编写一个程序实现以下要求: 1、输入圆柱体的半径(radius)和高(high)... 阅读全文
posted @ 2014-08-13 21:32 2014acm 阅读(386) 评论(0) 推荐(0) 编辑
摘要:C语言:选择结构5(三角形的种类)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:885 测试通过:506描述 输入三角形的3条边长(均为正整数),如果不能构成一个三角形,则输出“not a triang... 阅读全文
posted @ 2014-08-13 21:31 2014acm 阅读(203) 评论(0) 推荐(0) 编辑
摘要:C语言:顺序结构3(球的体积)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:880 测试通过:610描述编写程序,输入球到半径,计算并输出球的体积。圆周率取3.14159。输入球到半径。输出球的体积。注意:保... 阅读全文
posted @ 2014-08-13 21:30 2014acm 阅读(196) 评论(0) 推荐(0) 编辑
摘要:101两点距离时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 输入两点坐标(X1,Y1),(X2,Y2)(0#include main(){ int N ; float a,b,c,d; double s; scanf("%d\n",&N);... 阅读全文
posted @ 2014-08-13 21:17 2014acm 阅读(174) 评论(0) 推荐(0) 编辑
摘要:题目242题目信息运行结果本题排行讨论区计算球体积时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 根据输入的半径值,计算球的体积。输入输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。(0#include using namespace std;#define ... 阅读全文
posted @ 2014-08-13 21:15 2014acm 阅读(179) 评论(0) 推荐(0) 编辑
摘要:在C/C++语言里,&代表取地址或者“位与”运算1、取变量的地址:&变量名,这将获得该变量的地址,例:int a = 1, &p = a。2、进行位与运算,格式是:变量1&变量2,进行计算时,将会把类型提升为int。“位与”运算是“位运算”的一种,运算法则是在二进制数下,相同位的两个数字都为1,则为... 阅读全文
posted @ 2014-08-13 20:02 2014acm 阅读(199) 评论(0) 推荐(0) 编辑
摘要:# include int a[25][1010], vis[25][1010] ;int n, m, INF = 0x0f0f0f0f ;int max(int a, int b){return a>b?a:b;}int dfs(int x, int y){ int i, rtn = -IN... 阅读全文
posted @ 2014-08-13 16:26 2014acm 阅读(130) 评论(0) 推荐(0) 编辑
摘要:#include #include #define N 10005using namespace std;int a[N],b[N],n,maxlen=1;int f( int x){int i,m,t;if ( b[x]>0 ) return b[x];m=1;for (i=0;ia[i]) m=... 阅读全文
posted @ 2014-08-13 15:39 2014acm 阅读(119) 评论(0) 推荐(0) 编辑
摘要:#include #define N 10005using namespace std;int a[N],n,maxlen=1;int f( int x){int i,t,m;if (xa[i]) { m=max(m,t+1); if (m>maxlen) maxlen=m; } } return... 阅读全文
posted @ 2014-08-13 15:38 2014acm 阅读(127) 评论(0) 推荐(0) 编辑
摘要:#include #define N 10005using namespace std;int a[N],n;int f( int x){ int i,t; if (x==0) return 1; //第一个元素 下标为0 for (t=0,i=0;i=a[i]) t... 阅读全文
posted @ 2014-08-13 15:36 2014acm 阅读(337) 评论(0) 推荐(0) 编辑
摘要:#include #define N 15using namespace std;int a[N]={1};void yanghui(int n){int i,j;for(i=0;i=1;j--) a[j]+=a[j-1]; }} int main() { int i,j,n; cin>>n; ya... 阅读全文
posted @ 2014-08-13 11:44 2014acm 阅读(148) 评论(0) 推荐(0) 编辑
摘要:探索1#include #define N 15using namespace std;int a[N]={1};void yanghui(int n){int i,j;for(i=0;i>n; yanghui(n); return 0;}#include #define N 15using nam... 阅读全文
posted @ 2014-08-13 11:26 2014acm 阅读(211) 评论(0) 推荐(0) 编辑
摘要:#include #define N 15using namespace std;int a[N][N];void yanghui(int n){ int i,j; for(i=0;i>n; yanghui(n); for(i=0;i#define N 15using names... 阅读全文
posted @ 2014-08-13 11:07 2014acm 阅读(193) 评论(0) 推荐(0) 编辑
摘要:#include int main( ){ int a,b,c,s ; s=0 ;for(a=1; aint main( ){ int a,b,c,s ; s=0 ;for(a=1; a<=9; a++)for(b=0; b<=9; b++)for(c=0; c<=9... 阅读全文
posted @ 2014-08-12 21:33 2014acm 阅读(146) 评论(0) 推荐(0) 编辑
摘要:#include int main( ){ int a,b,c,i;for(i=100;iint main( ){ int a,b,c,he,i;for(i=100;iint main( ){ int a,b,c,i,s ; s=0 ;for(i=100;iint m... 阅读全文
posted @ 2014-08-12 21:30 2014acm 阅读(176) 评论(0) 推荐(0) 编辑
摘要:#include int f(int n){ if (n==1) return 1; else return f(n-1)+n; }int main(void){ printf("%d\n",f(100));} 阅读全文
posted @ 2014-08-12 21:23 2014acm 阅读(139) 评论(0) 推荐(0) 编辑
摘要:hnldyhy// poj 1651 矩阵连乘 DP #include #include using namespace std;int dp[103][103],s[103];int main(){ int n,i,j,k,min; cin>>n; for(i=1;i>s[i]... 阅读全文
posted @ 2014-08-12 21:09 2014acm 阅读(157) 评论(0) 推荐(0) 编辑
摘要:#include int dp[12888];int w[3408],d[3408];int max(int x,int y) { return x>y?x:y; }int main(){ int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF... 阅读全文
posted @ 2014-08-12 21:02 2014acm 阅读(82) 评论(0) 推荐(0) 编辑
摘要:#include#define max(a,b) (a)>(b)?(a):(b)int dp[12888];int w[3408],d[3408];int main(){ int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF) { for(i=... 阅读全文
posted @ 2014-08-12 21:00 2014acm 阅读(117) 评论(0) 推荐(0) 编辑
摘要:#includeint main(){int a[10][10];int i,j; for(i=0;i#define N 10int main(){int a[N][N], i,j; for(i=0;i#define N 50void YangHui(int a[][N],int n){ int i... 阅读全文
posted @ 2014-08-12 20:57 2014acm 阅读(168) 评论(0) 推荐(0) 编辑
摘要:// 动态规划求最少钱币枚数#include int a[20],c[20][3000],k,n;int min(int x,int y){ return x>y?y:x; }int main(){ int i,j; scanf("%d",&k); for (i=0; i=... 阅读全文
posted @ 2014-08-12 20:44 2014acm 阅读(295) 评论(0) 推荐(0) 编辑
摘要:#includeint max(int x,int y){ int z; if (x>y) z=x; else z=y; return z;}int max(int a,int b){ return a > b ? a : b;}int main(){ int t... 阅读全文
posted @ 2014-08-12 20:26 2014acm 阅读(207) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[1005], w[105],v[105],T,M;int max(int x,int y) { return x>y?x:y; }void f( ){ int i,j; for (i... 阅读全文
posted @ 2014-08-12 20:14 2014acm 阅读(126) 评论(0) 推荐(0) 编辑
摘要:70 371 10069 11 2#include #include using namespace std;int dp[105][1005], w[105],v[105],T,M;int max(int x,int y){ return x>y?x:y; }void f( ){ ... 阅读全文
posted @ 2014-08-12 20:07 2014acm 阅读(199) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[105][1005], w[105],v[105],T,M,;int max(int x,int y) { return x>y?x:y; }int f(int x,int y){ int t; if (d... 阅读全文
posted @ 2014-08-12 20:05 2014acm 阅读(150) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int dp[105][1005], w[105],v[105],T,M,;int max(int x,int y) { return x>y?x:y; }int f(int x,int y){ int t; if (... 阅读全文
posted @ 2014-08-12 20:04 2014acm 阅读(244) 评论(0) 推荐(0) 编辑
摘要:rqnoj 15 采药 原创 2015年12月14日 09:03:20 标签: c语言 411 原创 2015年12月14日 09:03:20 标签: c语言 411 题目描述 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出 阅读全文
posted @ 2014-08-12 20:02 2014acm 阅读(168) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int dp[105][1005],w[105],v[105] ;int max(int a,int b) { return a > b ? a : b; }int f(int x,int y){ int t ; if(dp[x][... 阅读全文
posted @ 2014-08-12 19:59 2014acm 阅读(143) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int dp[105][1005],w[105],v[105] ;int max(int a,int b) { return a > b ? a : b; }int f(int x,int y){ int t ; if(dp[x][... 阅读全文
posted @ 2014-08-12 19:54 2014acm 阅读(296) 评论(0) 推荐(0) 编辑
摘要:物品质量 w[0] w[1] w[2] ....... w[n] 背包容量c T物品价值 v[0] v[1] v[2] ....... v[n] 物品种类 n N(一)设DP(x,y) 表示 从前x项物品中 取出装入 体积为y的背包 的 物品的... 阅读全文
posted @ 2014-08-12 19:26 2014acm 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2014-08-12 18:58 2014acm 阅读(83) 评论(0) 推荐(0) 编辑
摘要:#include int f(int a,int b){ if(aint f(int a,int b){ if(b==0) return 1 ; if(a#define MAX 200void main( ){ int... 阅读全文
posted @ 2014-08-12 18:43 2014acm 阅读(96) 评论(0) 推荐(0) 编辑
摘要:ZOJ 1027/*zoj 1027 poj 1080 思路: 三种状态,取最大值:s1[i]和s2[j]配 :dp[i-1][j-1]+cost[my[s1[i]]][my[s2[j]]];s1[i]和'-' 配: dp[i-1][j]+cost[my[s1[i]]][my['-']];s2[... 阅读全文
posted @ 2014-08-12 18:39 2014acm 阅读(172) 评论(0) 推荐(0) 编辑
摘要:// 0-1背包问题的普通递归算法#include #define M 10int w[M]={5,3,2,1},v[M]={4,4,3,1};int limit_w=7,maxv=0,n=4; void find(int i,int tw,int tv) //从第i种物品开始,当前已有的重量tw和... 阅读全文
posted @ 2014-08-12 18:36 2014acm 阅读(136) 评论(0) 推荐(0) 编辑
摘要:#include int n,ans, a[1001],b[1001];int main(){int i,j;scanf("%d",&n);for(i=1;ia[j]&&b[j]+1>b[i]) b[i]=b[j]+1;ans=1;for(i=1;i<=n;i++)if(ans<b[i]) ... 阅读全文
posted @ 2014-08-12 18:28 2014acm 阅读(98) 评论(0) 推荐(0) 编辑
摘要:poj 1836#include #include using namespace std ;const int MAX = 1005 ;double m[MAX] ;int dp1[MAX] , dp2[MAX] ;int main(){ int n ; while ( cin >> ... 阅读全文
posted @ 2014-08-12 18:17 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:zoj 1733#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N];int max(int a,int b){ return a>b ? a : b ; }void f(int... 阅读全文
posted @ 2014-08-12 18:12 2014acm 阅读(112) 评论(0) 推荐(0) 编辑
摘要:#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N],ans,len1,len2;int max(int a,int b){ return a>b ? a : b ; }int f(in... 阅读全文
posted @ 2014-08-12 18:10 2014acm 阅读(120) 评论(0) 推荐(0) 编辑
摘要:#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N],ans,len1,len2;int max(int a,int b){ return a>b ? a : b ; }int f(in... 阅读全文
posted @ 2014-08-12 18:06 2014acm 阅读(127) 评论(0) 推荐(0) 编辑
摘要:#include#includeint main(){ int students,max=0; int i,j; int a[100],b[100],c[100]; scanf("%d",&students); for(i=0;ib[i]) b[i]=b[j]+1; ... 阅读全文
posted @ 2014-08-12 17:51 2014acm 阅读(200) 评论(0) 推荐(0) 编辑
摘要:#include #define MAX 50+1int fib(int n){ int i,a[MAX]; a[1]=a[2]=1; for (i=3; i<=n; i++) a[i]=a[i-1]+a[i-2]; return a[n];}void main( )... 阅读全文
posted @ 2014-08-12 17:40 2014acm 阅读(198) 评论(0) 推荐(0) 编辑
摘要:#include #define MAX 50+1int a[MAX];int fib(int n){ if (a[n]==-1) return a[n]=fib(n-1)+fib(n-2); else return a[n]; }int main( ){ int i,n;... 阅读全文
posted @ 2014-08-12 17:36 2014acm 阅读(140) 评论(0) 推荐(0) 编辑
摘要:#include int fib(int n){ if (n<=1) return 1; else return fib(n-1)+fib(n-2); }int main( ){ int n; scanf("%d",&n); printf("%d\n" ,fib( ... 阅读全文
posted @ 2014-08-12 17:32 2014acm 阅读(147) 评论(0) 推荐(0) 编辑
摘要:#include #include#includeusing namespace std;char a[10002];int b[10002];int n,ans;int dp(int x){ int i,j,max; b[0]=1; for(i=1;i>n;for(i=1;i#include#... 阅读全文
posted @ 2014-08-12 17:16 2014acm 阅读(74) 评论(0) 推荐(0) 编辑
摘要://记忆式搜索 #include #include#includeusing namespace std;char a[10002];int b[10002];int n,ans;int f(int x){ int i,t; if(b[x]>0) return b[x]; b[x]=1; for(... 阅读全文
posted @ 2014-08-12 17:08 2014acm 阅读(192) 评论(0) 推荐(0) 编辑
摘要:#include #include#includeusing namespace std;char a[10002];int b[10002];int n,ans;int f(int x){ int i,t; for(i=0;i>n;for(i=1;i#include#includeusing n... 阅读全文
posted @ 2014-08-12 17:04 2014acm 阅读(202) 评论(0) 推荐(0) 编辑
摘要:hnldyhy(303882171) 11:28:19poj 1088//DP #include using namespace std; int a[102][102],b[102][102]; int r, c,ans; int f( int i, int j ) { int max... 阅读全文
posted @ 2014-08-12 16:49 2014acm 阅读(125) 评论(0) 推荐(0) 编辑
摘要:不能通过---------------递推,,,,自顶向下*************************************************************************************************************************... 阅读全文
posted @ 2014-08-12 16:43 2014acm 阅读(166) 评论(0) 推荐(0) 编辑
摘要://记忆式搜索 #include #include using namespace std; int a[101][101],n,b[101][101]; int f(int i,int j) { if ( b[i][j]!=-1 ) return b[i][j]; if ( i==n... 阅读全文
posted @ 2014-08-12 16:28 2014acm 阅读(146) 评论(0) 推荐(0) 编辑
摘要:#include #includeusing namespace std;int a[1005][1005],b[1005][1005];int n;int max(int x, int y){ return x>y?x:y ; }int f(int i,int j){ if(b[... 阅读全文
posted @ 2014-08-12 15:59 2014acm 阅读(121) 评论(0) 推荐(0) 编辑
摘要:#include //2084 hdu c++#includeusing namespace std;int a[105][105],b[105][105];int n;int max(int x, int y){ return x>y?x:y ; }int f(int i,int... 阅读全文
posted @ 2014-08-12 15:56 2014acm 阅读(159) 评论(0) 推荐(0) 编辑
摘要://本题用DP算法: 从一组数据中找一组递增数列且和为最大,假如我们从最后面往前找,每次都要找出前面比本身的小的数 ,//并加上f[j],就是此时f[j]最大的值//用f[ ]记下相应的位置的最大和,f[ i ]=max(num[ i ] ,f[ i ]+num[ j ] ),其中0num[ j ]... 阅读全文
posted @ 2014-08-12 11:29 2014acm 阅读(89) 评论(0) 推荐(0) 编辑
摘要:#include#include using namespace std;int n,a[1001],b[1001];int main(){ int i,j,best=0; scanf("%d",&n); for(i=1;ia[j]&&b[j]>maxx) maxx=b[j]; b[i]=maxx... 阅读全文
posted @ 2014-08-12 10:33 2014acm 阅读(101) 评论(0) 推荐(0) 编辑
摘要://Time Limit Exceeded 普通递归 自顶向下#include #define N 105 #includeusing namespace std;int a[N][N];int n;int max(int x, int y){ return x>y?x:y ; }int maxs... 阅读全文
posted @ 2014-08-12 10:02 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要:if(n%2==1) 等价 if( n&1 ) 位与&是位与操作符,n&1, n的最低位是1 1&1 就是 1不是将n的二进制形式与00000000 00000001按位做与操作。这时,只... 阅读全文
posted @ 2014-08-11 23:01 2014acm 阅读(182) 评论(0) 推荐(0) 编辑
摘要:zjut 1176 菲波那契数" - 博客后台管理 - 博客园http://i.cnblogs.com/EditPosts.aspx?postid=3887297 #include#include#includeusing namespace std;int main(int argc, char... 阅读全文
posted @ 2014-08-11 22:46 2014acm 阅读(92) 评论(0) 推荐(0) 编辑
摘要:#include #include int a[31][31] = {0}; using namespace std;int main(){ a[0][0] = 1; int i = 0, j = 0, n = 0; for(i = 1; i > n) { ... 阅读全文
posted @ 2014-08-11 22:42 2014acm 阅读(88) 评论(0) 推荐(0) 编辑
摘要:(a+b)%c===(a%c + b%c ) %c#includeusing namespace std;int a[5000]={0,0,1};int main(){ int i,p,k; while(cin>>p>>k){ if(p==0&&k==0) break;for(i=3;iusing ... 阅读全文
posted @ 2014-08-11 22:38 2014acm 阅读(214) 评论(0) 推荐(0) 编辑
摘要:#include int fib(int n){if(nint fib(int n){ if(n#define MAX 50+1int a[MAX];int fib(int n){ if (a[n]==-1) return a[n]=fib(n-1)+fib(n-2)... 阅读全文
posted @ 2014-08-11 22:35 2014acm 阅读(402) 评论(0) 推荐(0) 编辑
摘要:n==10 20 30 40 50 46 体验一下,感受一下,运行时间#include int fib(int n){ if (nint fib(int n){ if (nint fib[50]={0,1}; //使用打表void in... 阅读全文
posted @ 2014-08-11 21:47 2014acm 阅读(219) 评论(0) 推荐(0) 编辑
摘要:#includeusing namespace std;int n,k,a[10000];int binsearch(int low,int high){ int i,len,s;while(lowk) low=len+1; else if(s>n>>k) ... 阅读全文
posted @ 2014-08-11 21:42 2014acm 阅读(86) 评论(0) 推荐(0) 编辑
摘要:#include #include #define N 4000using namespace std;int a[N],b[N],c[N],d[N],ab[N*N],cd[N*N];int main(){int n,ans,i,j,k;while(scanf("%d",&n)!=EOF){ ... 阅读全文
posted @ 2014-08-11 21:41 2014acm 阅读(102) 评论(0) 推荐(0) 编辑
摘要:群#include #include int a[220][220];int x[220],y[220],n;int init(){ int i,j; for(i=0;iy?x:y;}int floyd(){ int i,j,k,t; for(k=0;kt) a[i][j]=t; ... 阅读全文
posted @ 2014-08-11 21:29 2014acm 阅读(106) 评论(0) 推荐(0) 编辑
摘要:群#include #include #include #include #include using namespace std;#include int a[205][205];int main(int argc, char *argv[]){ int m,n,i,j,k,r,p=0; stri... 阅读全文
posted @ 2014-08-11 21:26 2014acm 阅读(97) 评论(0) 推荐(0) 编辑
摘要://1874#include #define N 205#define INF 10000000int g[N][N],bz[N],dist[N],s,t,n,m;void Dijkstra(int s){ int i,j,min,k,x; for (i=1;iw) g[x... 阅读全文
posted @ 2014-08-11 21:22 2014acm 阅读(119) 评论(0) 推荐(0) 编辑
摘要:c提交#includedouble map[102][102];void clear(int n){ int i,j;for(i=0;i<n;i++){ for(j=0;j<n;j++) { map[i][j]=-1; }}}double floyed(int n){int i,j,k... 阅读全文
posted @ 2014-08-11 21:20 2014acm 阅读(165) 评论(0) 推荐(0) 编辑
摘要:// 顶点从1 开始 floyed#include #define N 201#define INF 100000 int g[N][N],n,m;void floyed() { int i,j,k; for(k=1;kg[i][k]+g[k][j]) g[i][j]=g[i][k]+g[... 阅读全文
posted @ 2014-08-11 21:16 2014acm 阅读(130) 评论(0) 推荐(0) 编辑
摘要:// 顶点从1 开始 floyedvoid floyed() { int i,j,k; for(k=1;kg[i][k]+g[k][j]) g[i][j]=g[i][k]+g[k][j] ; } }// 顶点从0 开始 floyedvoid floyed() { int i... 阅读全文
posted @ 2014-08-11 21:12 2014acm 阅读(107) 评论(0) 推荐(0) 编辑
摘要:#include #define N 205#define INF 10000000int g[N][N],bz[N],dist[N],s,t,n,m;void Dijkstra(int s){ int i,j,min,k,x; for (i=1;i<=n;i++) { d... 阅读全文
posted @ 2014-08-11 21:04 2014acm 阅读(97) 评论(0) 推荐(0) 编辑
摘要:��.(790684394) 17:34:42#include #define N 2000#define INF 100000000int g[N][N],bz[N],dist[N],s,t,n,z;void Dijkstra(int s){ int i,j,min,k,x; f... 阅读全文
posted @ 2014-08-11 21:03 2014acm 阅读(148) 评论(0) 推荐(0) 编辑
摘要://2544 G++ #include #define N 201#define INF 100000 int g[N][N],bz[N],dist[N],s,t,n,m;void Dijkstra(int s){ int i,j,min,k,x; for (i=1;i#define... 阅读全文
posted @ 2014-08-11 21:02 2014acm 阅读(134) 评论(0) 推荐(0) 编辑
摘要://1874#include #define N 205#define INF 10000000int g[N][N],bz[N],dist[N],s,t,n,m;void Dijkstra(int s){ int i,j,min,k,x; for (i=1;iw) g[x... 阅读全文
posted @ 2014-08-11 20:57 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:hnldyhy(303882171) 11:00:25// Dijkstra 邻接矩阵的下标从1开始 #include #define N 201#define INF 1000000000int g[N][N],bz[N],dist[N],s,t,n;void Dijkstra(int s){ ... 阅读全文
posted @ 2014-08-11 20:53 2014acm 阅读(125) 评论(0) 推荐(0) 编辑
摘要:/*最小生成树,用Prim算法使用BZ数组*/#include#define INF 200int g[110][110],bz[110],low[110];int min,ans,Q,n,a,b;void prim(){ int i,j,k,x; for (i=1;i<=n;i+... 阅读全文
posted @ 2014-08-11 20:46 2014acm 阅读(135) 评论(0) 推荐(0) 编辑
摘要://hnldyhy(303882171) 8:54:04#include // poj 1258#include using namespace std; #define N 105int p[N];void init (int n){ for (int i=1;i>n&&n>=3) ... 阅读全文
posted @ 2014-08-11 20:04 2014acm 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2014-08-11 20:00 2014acm 阅读(85) 评论(0) 推荐(0) 编辑
摘要:// poj 2421 prim/*最小生成树,用Prim算法有n个城镇,已知每两个城镇的距离,其中某些城镇之间的道路已经修好,要求用最少的路径修完剩下的城镇之间的路*/#include#define InF 2000int g[110][110],bz[110],low[110];int min,... 阅读全文
posted @ 2014-08-11 19:56 2014acm 阅读(164) 评论(0) 推荐(0) 编辑
摘要:#include // poj 1258 10.1.5.253 1505using namespace std; #define N 105 // 顶点的最大个数 (多写 int a[N][N],low[N],n,ans;int min(int x,int y){ ... 阅读全文
posted @ 2014-08-11 19:54 2014acm 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2014-08-11 19:49 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要:// hnldyhy(303882171) 15:56:57 // poj 1988/*思路:找到含X的那叠箱子的箱子总数减去X上面的箱子数再减1就是所要的答案。如果a堆在b上,那么b上面的箱子数就是等于含a的那叠箱子的总数;*/#include #define N 30001int p[N];i... 阅读全文
posted @ 2014-08-10 20:03 2014acm 阅读(156) 评论(0) 推荐(0) 编辑
摘要://1482#include #include using namespace std;int n,d;struct point{ int x,y,z,t;}a[1005];int find(int x ){ if(a[x].z==x) return x; else return ... 阅读全文
posted @ 2014-08-10 20:02 2014acm 阅读(100) 评论(0) 推荐(0) 编辑
摘要://1481#include #include using namespace std;#define N 50010int parent[N],sum;void init(){ for(int i=1;in || y> n) {sum--;continue;} ... 阅读全文
posted @ 2014-08-10 20:01 2014acm 阅读(139) 评论(0) 推荐(0) 编辑
摘要:#include #includeusing namespace std;#define N 50010int p[N]; void init(int n){ for(int i=1 ;i#include #include #include #include #include using name... 阅读全文
posted @ 2014-08-10 19:59 2014acm 阅读(184) 评论(0) 推荐(0) 编辑
摘要:// hnldyhy(303882171) 17:07:57// poj 1703#include int p[200005];void init(int n){ for (int i=1;i#includeusing namespace std;#define N 500001int ... 阅读全文
posted @ 2014-08-10 19:52 2014acm 阅读(142) 评论(0) 推荐(0) 编辑
摘要://1480#includeconst int MAX=50010; int p[MAX];int n,m;void init(int k) { for (int i=1; iconst int MAX=50010;int p[MAX];int n,m;void init(int k){fo... 阅读全文
posted @ 2014-08-10 19:47 2014acm 阅读(73) 评论(0) 推荐(0) 编辑
摘要:const int MAX=1010; //元素个数的最大值,根据题目修改int p[MAX];void init(int n) //n为实有元素个数{ for (int i=1; i<=n; i++) p[i]=i; }int find(int x) //查找{ if (x==p[x]) retu... 阅读全文
posted @ 2014-08-10 19:43 2014acm 阅读(94) 评论(0) 推荐(0) 编辑
摘要://hnldyhy(303882171) 11:12:46// zoj 1649//bfs +优先队列#include #include #include using namespace std;struct node{ int x; int y; int step;};bool... 阅读全文
posted @ 2014-08-10 19:35 2014acm 阅读(369) 评论(0) 推荐(0) 编辑
摘要://zoj 1586#include#includeusing namespace std;#define N 1005int a[N][N],low[N],n,ans;int b[N];int min(int x,int y){ return x#includeusing namespace... 阅读全文
posted @ 2014-08-10 19:31 2014acm 阅读(169) 评论(0) 推荐(0) 编辑
摘要:#include#includeusing namespace std;#define N 1005int a[N][N],low[N],n,ans;int b[N];int min(int x,int y){ return xci) { a[ai-1][bi-1]=c... 阅读全文
posted @ 2014-08-10 19:28 2014acm 阅读(97) 评论(0) 推荐(0) 编辑
摘要:输入:8 91 21 32 42 53 63 74 85 86 7// 图的BFS,使用C++队列#include #include #include using namespace std;#define N 10int g[N][N],bz[N],n,m;queue q;void BFS(in... 阅读全文
posted @ 2014-08-10 19:25 2014acm 阅读(243) 评论(0) 推荐(0) 编辑
摘要:#include // poj 1258 10.1.5.253 1505using namespace std; #define N 105 // 顶点的最大个数 (多写 int a[N][N],low[N],n,ans;int min(int x,int y){ ... 阅读全文
posted @ 2014-08-10 19:20 2014acm 阅读(99) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include using namespace std;struct node{ char msg[20]; int a,b;};struct cmp{ bool operator()(const node ... 阅读全文
posted @ 2014-08-10 19:02 2014acm 阅读(214) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include using namespace std; int main(){ vector phonelist; int testcast; cin >> testcast;... 阅读全文
posted @ 2014-08-10 19:00 2014acm 阅读(106) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include using namespace std;int main(){ int n,i,j; string s; mapm; map :: iterator it,it2; while(cin>>n... 阅读全文
posted @ 2014-08-10 18:59 2014acm 阅读(141) 评论(0) 推荐(0) 编辑
摘要:#include#includeusing namespace std;int main(void){ while(true) { set s; int n, doubles = 0; while(cin>>n && n) { if(n == -1) ... 阅读全文
posted @ 2014-08-10 18:56 2014acm 阅读(180) 评论(0) 推荐(0) 编辑
摘要:#include #include#define N 10int g[N][N];int bz[N];int n,m ;void DFS(int cur){ int j; bz[cur]=1; printf("V%d",cur); for(j=1;j<=n ;j++ ) if(g[cur][j] ... 阅读全文
posted @ 2014-08-10 18:50 2014acm 阅读(199) 评论(0) 推荐(0) 编辑
摘要:// zoj 2110#include #include #include using namespace std;char map[9][9]; //迷宫地图int n,m,t; //迷宫的大小,及迷宫的门会在第t... 阅读全文
posted @ 2014-08-10 18:47 2014acm 阅读(132) 评论(0) 推荐(0) 编辑
摘要:greater 从小到大lesser 总大到小#include#includeusing namespace std;int main(){ int n,m,t,x,y; long long s; priority_queue ,greater > my; cin>>n; ... 阅读全文
posted @ 2014-08-10 18:33 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:STL的队列和栈简单使用 #include #include #include #include #include #include using namespace std;int main(){ queue Q; stack S; int i; for(i=1;i M //例如 queue ... 阅读全文
posted @ 2014-08-10 18:25 2014acm 阅读(154) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include #include #include using namespace std;struct node{ int m,n; // bool f;};node hash[200];char s[1000];int main(... 阅读全文
posted @ 2014-08-10 18:23 2014acm 阅读(145) 评论(0) 推荐(0) 编辑
摘要:#include #include #include using namespace std; class rect //类 声明公有 { public: int ... 阅读全文
posted @ 2014-08-10 18:20 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:#include 头文件atof 将字符串 转化为 一个双精度值 int atof(a) #include #includedouble exp(){ char a[20];scanf("%s",a) ;switch(a[0]) { case'+': re... 阅读全文
posted @ 2014-08-10 18:13 2014acm 阅读(103) 评论(0) 推荐(0) 编辑
摘要:#include#include#includeusing namespace std;int main(){int n,i;char s[100];char s1[100],s2[100],s3[100];scanf("%d%*c",&n);for(i=1;i#include using name... 阅读全文
posted @ 2014-08-10 18:05 2014acm 阅读(108) 评论(0) 推荐(0) 编辑
摘要:C语言:数组8(统计各分数段的人数)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:491 测试通过:298描述输入一个班C语言的考试成绩,统计0-59、60-69、70-79、80-89、90-100每个分数... 阅读全文
posted @ 2014-08-10 17:55 2014acm 阅读(294) 评论(0) 推荐(0) 编辑
摘要:极目,远眺(752284118) 16:03:43poj 1002 用C++提交AC,G++超时#include #include #include #include #include using namespace std;map my;char a[30]="22233344455566677... 阅读全文
posted @ 2014-08-10 17:53 2014acm 阅读(182) 评论(0) 推荐(0) 编辑
摘要:#include #include #include //头文件 using namespace std;map my; //全局变量 0 map ::iterator it ; //指针 int main( ){ int i ; strin... 阅读全文
posted @ 2014-08-10 17:52 2014acm 阅读(138) 评论(0) 推荐(0) 编辑
摘要:#include //从小到大排列#include#includeusing namespace std;int main(){ int i,x; vectormy ; for(i=1;i>x; my.push_back(x); } sort(my.begin(),my.end()); f... 阅读全文
posted @ 2014-08-10 17:47 2014acm 阅读(99) 评论(0) 推荐(0) 编辑
摘要:#include #includeusing namespace std;bool cmp(int a,int b) { return a>a[i] ; sort(a,a+10); for(i=0;i#includeusing namespace std;int main( ){ int ... 阅读全文
posted @ 2014-08-10 17:37 2014acm 阅读(177) 评论(0) 推荐(0) 编辑
摘要:#include #includeusing namespace std;int a[5];int main( ){ int i; for(i=0;i>a[i] ; sort(a,a+5); for(i=0;i#includeusing namespace std;int a[5];boo... 阅读全文
posted @ 2014-08-10 17:21 2014acm 阅读(125) 评论(0) 推荐(0) 编辑
摘要:accept#include#include#include#includeusing namespace std;char ss[20005][25];int num[20005];int n,m;int cmp(const void * a,const void * b){ int i,a... 阅读全文
posted @ 2014-08-10 17:15 2014acm 阅读(257) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;int main(){ int i,k,n,a[10000]; cin>>n; for(i=0;i>a[i]; sort(a,a+n); cout#include using name... 阅读全文
posted @ 2014-08-10 16:59 2014acm 阅读(83) 评论(0) 推荐(0) 编辑
摘要:算法分析与设计:搜索(素数环)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte 总提交:178 测试通过:35描述将1-n这n个数摆成一个环,要求相邻的两个数的和是一个素数,编程输出所有可能的解。输入包括多组数据,每组1个数n。nusin... 阅读全文
posted @ 2014-08-10 16:31 2014acm 阅读(164) 评论(0) 推荐(0) 编辑
摘要:小试探#include #includestruct word{ char a[20],b[20];}w[100005];int main(int argc, char *argv[]){ int len=0; char s[100],x[20],y[20]; int i; while(gets(s... 阅读全文
posted @ 2014-08-10 11:18 2014acm 阅读(162) 评论(0) 推荐(0) 编辑
摘要:#includemain(){ float x=2.5,y,x1=2.5,a,b,c,d,max,min; scanf("%f%f%f%f",&a,&b,&c,&d); do { y=x-(a*x*x*x+b*x*x+c*x+d)/(3*a*x*x+2*b*x+... 阅读全文
posted @ 2014-08-10 11:11 2014acm 阅读(102) 评论(0) 推荐(0) 编辑
摘要:#include int main(){ float a,b,c,d,x,y,max,min; max=10; min=-10; scanf("%f%f%f%f",&a,&b,&c,&d); { x=(max+min)/2; y=a*... 阅读全文
posted @ 2014-08-10 11:07 2014acm 阅读(96) 评论(0) 推荐(0) 编辑
摘要:#includeint f(int a[],int low,int high,int x){ int mid; while (lowx) high=mid-1; else if(a[mid]int f(int a[],int low,int high,int x)... 阅读全文
posted @ 2014-08-10 10:46 2014acm 阅读(87) 评论(0) 推荐(0) 编辑
摘要:#include #include #include #include using namespace std;int a,b,used[200020];queueq;int ok(int n){ if(n = 0&&used[n]==0) return 1; ... 阅读全文
posted @ 2014-08-10 08:23 2014acm 阅读(139) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;const int N=100;const int M=100;typedef struct //定义迷宫结构 { char c; short int p_row,p_col,step;}Maze; Maze a[N][... 阅读全文
posted @ 2014-08-09 20:03 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要:#include main(){ int k,x,y,n; scanf("%d",&n); while(n--) { scanf("%d",&k); for(x=k+1;xk*(x+y))break; if(x*y==... 阅读全文
posted @ 2014-08-09 19:53 2014acm 阅读(148) 评论(0) 推荐(0) 编辑
摘要:C++:泛型编程stack(括号匹配)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:72 测试通过:39描述假设表达式中包含一种括号:圆括号,其嵌套顺序随意,即(()())或(())等为正确的格式,)(或((... 阅读全文
posted @ 2014-08-09 19:52 2014acm 阅读(1957) 评论(0) 推荐(0) 编辑
摘要:#include int main(){ int n,i,j,s,k,a[10000]; scanf("%d",&n); { s=0; k=0; for (j=1;jint main(){ int n,i,j,s; scanf("%d",&n... 阅读全文
posted @ 2014-08-09 19:49 2014acm 阅读(125) 评论(0) 推荐(0) 编辑
摘要:完数?时间限制:1000 ms | 内存限制:65535 KB 难度:1描述 一个数如果恰好等于不等于它本身的所有因子之和,那么这个数就被称为"完数"。例如,6的因子为1,2,3,而6=1+2+3,因此,6是完数。要求给定一个整数n,请编写程序,确定n是否是完数。输入每组数据输入一个n(1int... 阅读全文
posted @ 2014-08-09 19:48 2014acm 阅读(107) 评论(0) 推荐(0) 编辑
摘要:题目96题目信息运行结果本题排行讨论区n-1位数时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。输入第一行为M,表示测试数据组数。接下来M行,每行包含一个测试数据... 阅读全文
posted @ 2014-08-09 19:47 2014acm 阅读(110) 评论(0) 推荐(0) 编辑
摘要:开灯问题时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2 的倍数的开关(这些灯将被关掉),第3 个人按下所有编号为3的倍数的开关(其中关掉的灯将被打开,开着的灯将被关闭),依此类推。一共有k个人,问最后... 阅读全文
posted @ 2014-08-09 19:46 2014acm 阅读(145) 评论(0) 推荐(0) 编辑
摘要:题目74题目信息运行结果本题排行讨论区小学生算术时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 很多小学生在学习加法时,发现“进位”特别容易出错。你的任务是计算两个三位数在相加时需要多少次进位。你编制的程序应当可以连续处理多组数据,直到读到两个0(这是输入结束标记)。输入... 阅读全文
posted @ 2014-08-09 19:44 2014acm 阅读(138) 评论(0) 推荐(0) 编辑
摘要:奇偶数分离时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 有一个整型偶数n(2 int main() { int N; scanf("%d",&N); while(N--) { int n; scanf("%d",&n); ... 阅读全文
posted @ 2014-08-09 19:43 2014acm 阅读(176) 评论(0) 推荐(0) 编辑
摘要:#includemain(){ int a[5]={2,4,6,8,10}, *p , **k; p=a; k=&p; printf("%d ",*(p++)); printf("%d\n",**k);}//*p++先进行*p的操作,然后是p++,所以*p++的结果是数组的第一个元素,即2//k... 阅读全文
posted @ 2014-08-09 19:37 2014acm 阅读(137) 评论(0) 推荐(0) 编辑
摘要:101两点距离时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 输入两点坐标(X1,Y1),(X2,Y2)(0#include main(){ int N ; float a,b,c,d; double s; scanf("%d\n",&N);... 阅读全文
posted @ 2014-08-09 19:36 2014acm 阅读(135) 评论(0) 推荐(0) 编辑
摘要:1295C语言:选择结构7(成绩转换)时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:901 测试通过:593描述给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。 90分以上为A, 8... 阅读全文
posted @ 2014-08-09 19:34 2014acm 阅读(233) 评论(0) 推荐(0) 编辑
摘要:阶乘因式分解(二)时间限制:3000ms | 内存限制:65535KB难度:3描述给定两个数n,m,其中m是一个素数。将n(0int main( ){ int count,n,m,i,ii,t; scanf("%d",&t); while(t--) { count=0; scanf(... 阅读全文
posted @ 2014-08-09 19:33 2014acm 阅读(186) 评论(0) 推荐(0) 编辑
摘要:阶乘因式分解(一)时间限制:3000ms | 内存限制:65535KB难度:2描述给定两个数m,n,其中m是一个素数。将n(0int main(){ int s1,n,m,s,j,i,ii; scanf("%d",&s1); while(s1--) { s=0; scanf("%d%d",&n... 阅读全文
posted @ 2014-08-09 19:31 2014acm 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Fibonacci数时间限制:3000ms | 内存限制:65535KB难度:1描述无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递归地定义为F(n)=1 ...........(n=1或n=2)F(n)=F(n-1)+F(n-2).....(n>2)... 阅读全文
posted @ 2014-08-09 19:29 2014acm 阅读(120) 评论(0) 推荐(0) 编辑
摘要:ASCII码排序时间限制:3000ms | 内存限制:65535KB难度:2描述输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。输入第一行输入一个数N,表示有N组测试数据。后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格。输出对于每组输入数据... 阅读全文
posted @ 2014-08-09 19:27 2014acm 阅读(149) 评论(0) 推荐(0) 编辑
摘要:括号配对问题时间限制:3000ms | 内存限制:65535KB难度:3描述现在,有一行括号序列,请你检查这行括号是否配对。输入第一行输入一个数N(0 #include #include #include using namespace std; int main() { int ... 阅读全文
posted @ 2014-08-09 19:25 2014acm 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1的个数时间限制:3000ms | 内存限制:65535KB难度:1描述小南刚学了二进制,他想知道一个数的二进制表示中有多少个1,你能帮他写一个程序来完成这个任务吗?输入第一行输入一个整数N,表示测试数据的组数(1int main(){ int m,N,count ;scanf("%d",&N);w... 阅读全文
posted @ 2014-08-09 19:24 2014acm 阅读(104) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;#include #include int main(){ int i,k,n,m; stacks; scanf("%d%d",&n,&m); while(n) { s.push(n%m); ... 阅读全文
posted @ 2014-08-09 19:00 2014acm 阅读(140) 评论(0) 推荐(0) 编辑
摘要:#include void change(int n,int m){if (n/m==0)printf ("%d",n%m);else{change(n/m,m);printf ("%d",n%m);}}int main(){ int n,m; while(scanf("%d%d",&n... 阅读全文
posted @ 2014-08-09 18:53 2014acm 阅读(104) 评论(0) 推荐(0) 编辑
摘要:zjut 1176 菲波那契数" - 博客后台管理 - 博客园http://i.cnblogs.com/EditPosts.aspx?postid=38872972098分拆素数和Problem Description把一个偶数拆成两个不同素数的和,有几种拆法呢? Input输入包含一些正的偶数,其... 阅读全文
posted @ 2014-08-09 17:57 2014acm 阅读(162) 评论(0) 推荐(0) 编辑
摘要:hdu 2021 发工资咯 - 2014年 - 博客园=========================rwkj 1412http://www.cnblogs.com/wc12436109/p/3871975.htmlrwkj 1410 -->算法分析与设计:贪心(找钱问题) 时间限制(普通/Jav... 阅读全文
posted @ 2014-08-09 17:39 2014acm 阅读(191) 评论(0) 推荐(0) 编辑
摘要:-->C语言:递归函数3(数组倒序) 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:786 测试通过:347描述输入多个整数,以0结束,将这些整数逆序后输出。要求:使用递归函数将数组倒序,在main中调用递归函数。 输入多个... 阅读全文
posted @ 2014-08-09 17:07 2014acm 阅读(243) 评论(0) 推荐(0) 编辑
摘要:先输出元素个数n,,,分别输出n个元素#include void f(int a[],int n){ int i,t; for (i=0; ivoid f(int a[],int n){ int i,t; for (i=0; ivoid f(int a[],int n){ ... 阅读全文
posted @ 2014-08-09 17:04 2014acm 阅读(157) 评论(0) 推荐(0) 编辑
摘要:一行数逆序数 - 博园少主 - 博客园http://www.cnblogs.com/wc1903036673/p/3870630.html#include int main ( ){int n,a[1000],s,t,k,i=0,j;scanf("%d",&n);while(n>=10){a[i+... 阅读全文
posted @ 2014-08-09 16:41 2014acm 阅读(161) 评论(0) 推荐(0) 编辑
摘要:#includeint main(){ int n,a,b,i; int sum=0 ; scanf("%d%d",&a,&b); { for (n=a;n=n) sum+=n; } printf("... 阅读全文
posted @ 2014-08-09 16:08 2014acm 阅读(106) 评论(0) 推荐(0) 编辑
摘要:#includeint main(){ int n,a,b,i; int j,s=0; int c[1000]; while ( scanf("%d%d",&a,&b)==2) { j=0; for (n=a;n=n) ... 阅读全文
posted @ 2014-08-09 15:47 2014acm 阅读(123) 评论(0) 推荐(0) 编辑
摘要:#includeusing namespace std;#include#includeint used[105][105];int a[8][2]={{0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};char s[105][105];in... 阅读全文
posted @ 2014-08-09 10:23 2014acm 阅读(90) 评论(0) 推荐(0) 编辑
摘要:#includechar grid[101][101];int n, m;int dir[8][2] = { {-1, -1}, {-1, 0}, {-1, 1}, { 0, 1}, { 1, 1}, { 1, 0}, { 1, -1}, { 0, -1}};void dfs(int x, int ... 阅读全文
posted @ 2014-08-09 10:21 2014acm 阅读(110) 评论(0) 推荐(0) 编辑
摘要:// 简单 bfs#include #includeusing namespace std;char map[110][110];int flag[110][110];int qu[11000][2],qe,qs,m,n;int add[8][2]={-1,-1, -1,0, -1,1, 0,-1,... 阅读全文
posted @ 2014-08-09 10:20 2014acm 阅读(145) 评论(0) 推荐(0) 编辑
摘要://BFS#include #include using namespace std;bool used[8][8];int move[8][2]={1,2, -1,2, -2,1, -2,-1, -1,-2, 1,-2, 2,-1, 2,1};struct position{ int i,j... 阅读全文
posted @ 2014-08-09 10:19 2014acm 阅读(170) 评论(0) 推荐(0) 编辑
摘要:#include#includeusing namespace std;struct point{ int x, y;};point bufa[8] ={ {-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};... 阅读全文
posted @ 2014-08-09 10:12 2014acm 阅读(118) 评论(0) 推荐(0) 编辑
摘要:// BFS#include #include int visited[301][301]; // visited 已经访问过了int dic[8][2]={{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-... 阅读全文
posted @ 2014-08-09 10:10 2014acm 阅读(124) 评论(0) 推荐(0) 编辑
摘要:#include#include#include#includeusing namespace std;struct point{ int x,y,step;}p;string map[211];int used[211][211];int f[4][2] = {{1,0},{0,1}... 阅读全文
posted @ 2014-08-08 17:26 2014acm 阅读(68) 评论(0) 推荐(0) 编辑
摘要:BFS#include #include #include #include #include #include using namespace std;struct node{ int x,y;};int dir[8][2]={-2,-1,-2,1,-1,-2,-1,2,1,-2,1,2,2... 阅读全文
posted @ 2014-08-08 11:26 2014acm 阅读(73) 评论(0) 推荐(0) 编辑
摘要:#include #include using namespace std;const int N=20;int g[N][N],bz[N]={0},n,flag=0;void bfs(int x){ int t,i;queue q;q.push(x); bz[x]=1;while (!q.emp... 阅读全文
posted @ 2014-08-08 09:50 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要:#include#include#include#includeusing namespace std;int s[55][55][55];int used[55][55][55];int bzx[55]={1,-1,0,0,0,0};int bzy[55]={0,0,1,-1,0,0};int b... 阅读全文
posted @ 2014-08-07 21:59 2014acm 阅读(101) 评论(0) 推荐(0) 编辑
摘要:#include using namespace std;int n,m, a[10];void DFS(int k){ if (k>n) { for (int i=1; i>n; DFS(1); return 0; }View Code#incl... 阅读全文
posted @ 2014-08-06 12:29 2014acm 阅读(131) 评论(0) 推荐(0) 编辑
摘要:数据结构:图的DFS遍历时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte 总提交:259 测试通过:183描述 从已给的连通图中某一顶点出发,沿着一些边访遍图中所有的顶点,且使每个顶点仅被访问一次,就叫做图的遍历。图的遍历的遍历有DFS和... 阅读全文
posted @ 2014-08-06 12:26 2014acm 阅读(288) 评论(0) 推荐(0) 编辑
摘要:描述输入二个整数a和b(2main(){ int a,b,max,min,n,m=0,i; while(scanf("%d%d",&a,&b)!=EOF) { max=a>b?a:b; min=a=min) { for... 阅读全文
posted @ 2014-08-05 23:54 2014acm 阅读(158) 评论(0) 推荐(0) 编辑
摘要:阶乘之和时间限制:3000 ms | 内存限制:65535 KB 难度:3描述 给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3!,如果是,则输出Yes,否则输出No;输入第一行有一个整数0int main( ){ int m,n,i,k... 阅读全文
posted @ 2014-08-05 23:44 2014acm 阅读(140) 评论(0) 推荐(0) 编辑
摘要:另一种阶乘问题时间限制:3000 ms | 内存限制:65535 KB 难度:1描述 大家都知道阶乘这个概念,举个简单的例子:5!=1*2*3*4*5.现在我们引入一种新的阶乘概念,将原来的每个数相乘变为i不大于n的所有奇数相乘例如:5!!=1*3*5.现在明白现在这种阶乘的意思了吧!现在你的任... 阅读全文
posted @ 2014-08-05 23:43 2014acm 阅读(148) 评论(0) 推荐(0) 编辑
摘要:5个数求最值时间限制:1000 ms | 内存限制:65535 KB 难度:1描述 设计一个从5个整数中取最小数和最大数的程序输入输入只有一组测试数据,为五个不大于1万的正整数输出输出两个数,第一个为这五个数中的最小值,第二个为这五个数中的最大值,两个数字以空格格开。样例输入1 2 3 4 5样... 阅读全文
posted @ 2014-08-05 23:42 2014acm 阅读(123) 评论(0) 推荐(0) 编辑
摘要:#includeint main(){int m,n,i,j,a,b;scanf("%d\n",&m);while(m--) // m组数据 { int sum=0; scanf("%d\n",&n); // 某一组 n个数 for(i=0;i<n;i+... 阅读全文
posted @ 2014-08-05 23:41 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要:#include #include #include using namespace std;bool cmp(int a,int b){ return a>b; }int main(){ int n,i; cin>>n; vector a(n); for(i=0;... 阅读全文
posted @ 2014-08-05 23:20 2014acm 阅读(145) 评论(0) 推荐(0) 编辑
摘要:字符串 统计 ,删除,连接,变换 - 2014年 - 博客园http://www.cnblogs.com/wc12436109/p/3872210.html?method=show&page=3#include void delchar(char*s,char c){ char *p=s ;... 阅读全文
posted @ 2014-08-05 22:05 2014acm 阅读(168) 评论(0) 推荐(0) 编辑
摘要:1-------冒泡排序-----选择排序 - 博园少主 - 博客园http://www.cnblogs.com/wc1903036673/p/3488277.html2====#include int main ( ){ int i,j,t,N ; scanf("%d",&N) ; ... 阅读全文
posted @ 2014-08-05 21:50 2014acm 阅读(130) 评论(0) 推荐(0) 编辑
摘要:冒泡排序===快速排序 - 博园少主 - 博客园http://www.cnblogs.com/wc1903036673/p/3499831.html 阅读全文
posted @ 2014-08-05 21:47 2014acm 阅读(98) 评论(0) 推荐(0) 编辑
摘要://冒泡排序 不是 #include #define N 100 void sort(int n,int a[]) { int i,j,t ; for(i=0;ia[j+1]) { t=a[j] ;a[j]=a[j+1] ;a[j+1]=t ;} } int main (... 阅读全文
posted @ 2014-08-05 21:45 2014acm 阅读(152) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示