上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页
摘要: #include <iostream>using namespace std;int main(){ long n; long old,cur; long sum; while(cin>>n && n!=0) { sum=n*5; old=0; while(n--) { cin>>cur; if(cur-old>0) sum+=(c... 阅读全文
posted @ 2010-05-12 11:11 VRS 阅读(139) 评论(0) 推荐(0)
摘要: //////////////////////////////////////最长升序数//用贪心法#include<iostream>using namespace std;int a[1005];int st[1005][2];int main(){ int i,j,n,num,max,sta; cin>>n; while(n--) { cin>>num; ... 阅读全文
posted @ 2010-05-12 11:11 VRS 阅读(221) 评论(0) 推荐(0)
摘要: #include<iostream>#include<queue>using namespace std;#define max 1001 //这里最后不能加分号,否则他把 max 的值定义为“1001;”int s[10][10];int t[10][10][5];int map[4][2]={{1,0},{0,1},{-1,0},{0,-1}};... 阅读全文
posted @ 2010-05-12 11:10 VRS 阅读(384) 评论(0) 推荐(0)
摘要: #include<iostream>#include<math.h>using namespace std;int main(){ long a,b; cin>>a>>b; long xmin,xmax,ymin,ymax; while(!(a==0 && b==0)) { xmin=ymin=2147483647; xmax=y... 阅读全文
posted @ 2010-05-12 11:10 VRS 阅读(139) 评论(0) 推荐(0)
摘要: //2104 颜色数目最多的气球的颜色//算法:先将给出的气球颜色输入进数组col[],然后逐个拿出数组col[]中第i个气球与剩下的n-i个比较,// 总共比较n(n-1)/2次,比较过程中把重复的比较减去,实际比较远少于n(n-1)/2。#include<iostream>using namespace std;struct Color{ char str[20]; //记录气球颜... 阅读全文
posted @ 2010-05-12 11:10 VRS 阅读(276) 评论(0) 推荐(0)
摘要: #include<iostream>#include<stdio.h>using namespace std;//记住,数据量大的时候scanf和cin的速度是相差很多的!int main(){ long num; long n; long sum;// cin>>n; scanf("%ld",&n); while(n--) { scanf("%ld"... 阅读全文
posted @ 2010-05-12 11:09 VRS 阅读(203) 评论(0) 推荐(0)
摘要: //////////////////////////////////////最长升序数//用dp+二分法//若用常规的做法用n^2的时间,用二分以后降为nlogn// 这种二分法很巧妙,先弄一个数组st[],每次读入a[i],找出在st[]中刚比它小的后一位st[k]//用a[i]替换s[k]。当k小于len时,这种替换不会改变最长链的最大数;当k=len时,最大链最大数//被改为一个更小的数a[... 阅读全文
posted @ 2010-05-12 11:08 VRS 阅读(163) 评论(0) 推荐(0)
摘要: #include<iostream>#include<math.h>using namespace std;//倒转函数int chang(int a){ int comp; int len=0; comp=a; while(comp!=0) { len++; comp/=10; } int out=0; int i; int bit; while(a!=0) { i... 阅读全文
posted @ 2010-05-12 11:08 VRS 阅读(175) 评论(0) 推荐(0)
摘要: #include <iostream>#include<iomanip>using namespace std;double st[1005];int main(){ double aver; int n,num; cin>>n; while(n--) { cin>>num; int i; aver=0; for(i=0;i<num;i... 阅读全文
posted @ 2010-05-12 11:07 VRS 阅读(176) 评论(0) 推荐(0)
摘要: #include<iostream>#include<queue>using namespace std;int MAP[6][3]={{1,0,0},{0,-1,0},{0,1,0},{-1,0,0},{0,0,1},{0,0,-1}};char a[30][30][30];int x,y,z;typedef struct{int z;int y;int x;int mo... 阅读全文
posted @ 2010-05-12 11:07 VRS 阅读(341) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页