摘要: #include<iostream>#include<cmath>using namespace std;char s[2][2];int main(){ int i; double h=0,t=0,d=0,temp,a[2]; while(cin>>s[0] && s[0][0]!='E') { cin>>a[0]>>... 阅读全文
posted @ 2010-05-12 13:38 VRS 阅读(166) 评论(0) 推荐(0)
摘要: 本来这篇文章应该开博第一天就来写的,鉴于前两天一直忙,没时间来写写。  其实我开博客原因很简单,并非要吸引点击率(本来就不是什么名人),只是想作为自己的小地盘,把一些学习工作的资料统一管理,收藏别人的好文章,分享自己的一点体会,作为与其他技术人员交流的平台。  写文章本来就不是自己的长项,但我也不想在这个博客里吹水,希望尽可能保留好一点的博文,可能借鉴别人的比较多吧。 阅读全文
posted @ 2010-05-12 13:34 VRS 阅读(115) 评论(0) 推荐(0)
摘要: 1.读计算机研究生最好要有实际际开发经验 这里所说的“有实际开发工作经验”通常应该具备:1)你已经认为C++和汇编语言都是很简单的语言,并能够自如地运用; 2)你完全理解STL为什么这么重要;3)你能够在30分钟之内想到正确的五子棋AI算法设计思路和方向;4)你能够独立地解决所有的编译与链接问题,哪怕你从来没有遇到的问题,你也不需要询问任何人;5)英文网站是你的首要信息来源... 阅读全文
posted @ 2010-05-12 13:23 VRS 阅读(235) 评论(0) 推荐(0)
摘要: 我编译的是在Ubuntu9.10下编译 Linux-2.6.33内核(原来内核Linux-2.6.31.……)首先需要前期准备,由于Ubuntu没有相关的编译工具,所以应该先安装Vim,build-essential,ncurses-dev这几个工具前期准备:1. 安装编译器(这其实是一个开发工具包) sudo apt-get install build-essenti... 阅读全文
posted @ 2010-05-12 13:16 VRS 阅读(1996) 评论(0) 推荐(2)
摘要: #include<iostream>using namespace std;char s[100];int a[100000];int main(){ int i,n,num,valu; cin>>n; while(n--) { cin>>s; cin>>num; for(i=0;i<num;i++) cin>>a[i]; i... 阅读全文
posted @ 2010-05-12 13:12 VRS 阅读(162) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////////最安全逃芝加哥路径//用单源最短路径法//在本题中的prev[]没有用到,这是用于构造最短路径的,本题不需要#include<iostream>#include<iomanip>using namespace std;#define MIN 0.0do... 阅读全文
posted @ 2010-05-12 13:11 VRS 阅读(490) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;int main(){ int num; int n; cin>>n; while(n--) { cin>>num; int i; int sum=0; for(i=0;i<num;i++) { int temp; cin>>temp; sum+=temp; ... 阅读全文
posted @ 2010-05-12 13:11 VRS 阅读(105) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;char st[1000];int main(){ while(cin.getline(st,990) && st[0]!='#') { int len=strlen(st); int i; long sum=0; for(i=0;i<len;i++) if(st[i]!=' ')... 阅读全文
posted @ 2010-05-12 13:11 VRS 阅读(211) 评论(0) 推荐(0)
摘要: #include<iostream>#include<math.h>using namespace std;int main(){ long n; cin>>n; while(n--) { long num; cin>>num; if(num<=10) cout<<num<<endl; else { long ... 阅读全文
posted @ 2010-05-12 13:09 VRS 阅读(186) 评论(0) 推荐(0)
摘要: #include<iostream>#include<string>using namespace std;struct Item{ char st[10]; bool flag;}from[25],to[25];void move(int sta_pos,int req_pos){ strcpy(to[req_pos].st,from[sta_pos].st); from... 阅读全文
posted @ 2010-05-12 13:09 VRS 阅读(204) 评论(0) 推荐(0)
摘要: #include<iostream.h>#include<math.h>//using namespace std;int main(){ int a,i,jishu; while(cin>>a && a!=0) { jishu=0; i=0; while(!i) { i=a%2; a/=2; if(i==0) jishu++; } ... 阅读全文
posted @ 2010-05-12 13:08 VRS 阅读(144) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;long st[50000];int main(){ int casenum; cin>>casenum; while(casenum--) { int n; cin>>n; int i; st[1]=0; for(i=2;i<=n;i++) cin>>st[... 阅读全文
posted @ 2010-05-12 13:08 VRS 阅读(155) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;bool fun(int n){ int sum=0; int temp=n; while(temp!=0) { sum+=temp%10; temp/=10; } temp=n; int sum2=0; while(temp!=0) { sum2+=temp%12; temp/=12; } if(su... 阅读全文
posted @ 2010-05-12 13:07 VRS 阅读(165) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;int main(){ int casenum; cin>>casenum; while(casenum--) { int sum,dif; cin>>sum>>dif; if(sum<dif || 1==(sum-dif)%2) //当sum<dif或一奇... 阅读全文
posted @ 2010-05-12 13:07 VRS 阅读(190) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;long st[1000000];int main(){ long casenum; cin>>casenum; while(casenum--) { long len,num; cin>>len>>num; long i; for(i=0;i<num;i++)... 阅读全文
posted @ 2010-05-12 13:06 VRS 阅读(235) 评论(0) 推荐(0)
摘要: #include<iostream>#include<string>using namespace std;struct MAN{ float sp; int a,b; char name[40];}man[3];int main(){ man[0].sp=4.5; man[0].a=150; man[0].b=200; strcpy(man[0].name,"Wide R... 阅读全文
posted @ 2010-05-12 13:05 VRS 阅读(152) 评论(0) 推荐(0)
摘要: //2345国王金币数//思路:先找出allnum(allnum<=n)使allnum=1+2+3+…+k,同时算出k,则f(allnum)=∑i^2,// 而f(n)=f(allnum)+(n-allnum)*(k+1). 已知公式∑i^2=k*(k+1)*(2k+1)/6#include<iostream>#include<math.h&g... 阅读全文
posted @ 2010-05-12 13:05 VRS 阅读(264) 评论(0) 推荐(0)
摘要: //关键是一条公式#include <iostream>#include <iomanip>#include <math.h>using namespace std;int main(){ int case_num; cin>>case_num; while(case_num--) { double ka,ori; //这里科学记录法可以作为输入 ... 阅读全文
posted @ 2010-05-12 13:05 VRS 阅读(217) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////// 1677474 2008-10-25 14:46:52 Accepted 2202 C++ 0 192 VRS //计算编码后再译码的种数//利用分治法,把字符串s二分为s1和s2,再把两部分的种数相乘//注意情况:合并s1和s2时,考虑相邻接的两数可以组成一个编码,还有对0的多种情况的讨论... 阅读全文
posted @ 2010-05-12 13:03 VRS 阅读(293) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;int main(){ int num; while(cin>>num && num!=-1) { int old,cur; int cost; int sum=0; old=0; while(num--) { cin>>cost>>cur; su... 阅读全文
posted @ 2010-05-12 13:01 VRS 阅读(153) 评论(0) 推荐(0)
摘要: #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 阅读(141) 评论(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 阅读(223) 评论(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 阅读(386) 评论(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 阅读(140) 评论(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 阅读(279) 评论(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 阅读(206) 评论(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 阅读(164) 评论(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 阅读(177) 评论(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 阅读(178) 评论(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 阅读(346) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////1889 n的倍数使11111…位数最少//思路:使题意转变为:给出n,算出最小的x满足10^x mod 9n = 1 (思路完全与1489一样)// 高精度,需要不断地缩小数据的规模。首先,n=1时,x=0;// 其次,每次把10^k nod 9n的余数乘10,得到是... 阅读全文
posted @ 2010-05-12 11:06 VRS 阅读(375) 评论(0) 推荐(0)
摘要: // 1904 海狸咬木// 一道简单的数学题#include <iostream>#include <math.h>#include <iomanip>using namespace std;#define Pi 3.1415926int main(){ double D,V; double d; while(cin>>D>>V &am... 阅读全文
posted @ 2010-05-12 11:06 VRS 阅读(252) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////////#include <iostream>using namespace std;int main(){ int A,a,B,b,C,c; while(cin>>A>>a>>B>>b>>C>>c &&a... 阅读全文
posted @ 2010-05-12 11:05 VRS 阅读(158) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////////#include <iostream>#include<iomanip>using namespace std;#define Pi 3.1415927int main(){ double dia,n,time; double ans; int counter=1;... 阅读全文
posted @ 2010-05-12 11:05 VRS 阅读(102) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////////#include <iostream>#include <algorithm>using namespace std;bool st[3000];int main(){ int n; int a,b; while(cin>>n) { cin>&g... 阅读全文
posted @ 2010-05-12 11:05 VRS 阅读(163) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////#include<iostream>#include<algorithm>using namespace std;int st[16];int main(){ int i; int ans; while(cin>>st[0] && st[0]!=-1) { an... 阅读全文
posted @ 2010-05-12 11:04 VRS 阅读(183) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////////#include<iostream>#include <iomanip>using namespace std;int main(){ float a,b; cin>>a; while(cin>>b && b!=999) { ... 阅读全文
posted @ 2010-05-12 11:04 VRS 阅读(140) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////////////////最长公共子串//dp经典例题#include<iostream>#include<string>using namespace std;char x[10000],y[10000];void LCSLength(int m,int n,... 阅读全文
posted @ 2010-05-12 11:03 VRS 阅读(236) 评论(0) 推荐(0)
摘要: /////////////////////////////////////////////////////////////#include<iostream>using namespace std;char st[10][10];int dimen[10];int main(){ int n; while(cin>>n && n!=-1) { int i;... 阅读全文
posted @ 2010-05-12 11:03 VRS 阅读(232) 评论(0) 推荐(0)
摘要: ///////////////////////////////////////////////////////数学题// 要交换次数少,关键是绕长度少于半圆的方向去交换// 我是以A1与An为分界把Ai与(An+1)-Ai交换到分界处,均交换i-1次,一直算到An/2,// 若n为奇数则再加上(An+1)/2的交换次数#include<iostream>using namespace ... 阅读全文
posted @ 2010-05-12 11:02 VRS 阅读(263) 评论(0) 推荐(0)
摘要: #include<iostream>#include<queue>using namespace std;char a[205][205],guodu[205][205];int t[205][205],guodu2[205][205];int map[4][2]={{1,0},{0,1},{0,-1},{-1,0}};int x,y,counter;struct node... 阅读全文
posted @ 2010-05-12 11:01 VRS 阅读(339) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////用鸽巢原理#include<iostream>using namespace std; int buc[1005];int main(){ int N,Q; while(cin>>N>>Q && !(N==0 && Q==0... 阅读全文
posted @ 2010-05-12 11:01 VRS 阅读(231) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////////////////带权的最长公共子串//dp经典例题#include<iostream>#include<string>using namespace std;char x[5000],y[5000];char ch[256];int a[256];vo... 阅读全文
posted @ 2010-05-12 11:00 VRS 阅读(183) 评论(0) 推荐(0)
摘要: /////////////////////////////////////////#include<iostream>using namespace std;int main(){ int n; while(cin>>n) { int i,count=0; int *a=new int[n+1]; for(i=0;i<n;i++) cin>>a[i]... 阅读全文
posted @ 2010-05-12 10:59 VRS 阅读(119) 评论(0) 推荐(0)
摘要: ////////////////////////////////////////////////////////////////////鸽巢原理做#include<iostream>using namespace std;int buc[10001],peo[20001];int main(){ int i,n,m,count; while(cin>>n>>m ... 阅读全文
posted @ 2010-05-12 10:58 VRS 阅读(158) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;int main(){ int n,u,d; int min,dis; while(cin>>n>>u>>d && !(n==0&&u==0&&d==0)) {/* min=n*2/(u-d); if(min*(u-d)/2+2... 阅读全文
posted @ 2010-05-12 10:57 VRS 阅读(186) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std;int main(){ int out,n,x,y; cin>>n; while(n--) { cin>>x>>y; if(x==y||x-y==2) { if(x%2==0) out=x+y; else out=x+y-1; cout<<out<&l... 阅读全文
posted @ 2010-05-12 10:55 VRS 阅读(127) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////2^x mod n = 1//给出n,算出最小的x满足2^x mod n = 1//思路:高精度,需要不断地缩小数据的规模。首先,n=1和n=2的倍数时不存在x,// 其次,每次把2^k nod n的余数乘2,得到是原(2^k)*2的余数,即2^(k+1)// 的余数。#includ... 阅读全文
posted @ 2010-05-12 10:55 VRS 阅读(208) 评论(0) 推荐(0)
摘要: //////////////////////////////////////////////////////////////最小花费路//用最小生成树Prim算法#include<iostream>using namespace std;#define MAX 1000int c[28][28];//先让输入转化为邻接矩阵储存void input(int n){ int i,j,num... 阅读全文
posted @ 2010-05-12 10:54 VRS 阅读(336) 评论(0) 推荐(0)
摘要: #include<iostream>#include<string>using namespace std;char shu[100],cun[50],zou[50];int main(){ int i,j,num,len,jishu1,jishu2,duwei,yiyou,yizou,zouren; while(cin>>num && num)... 阅读全文
posted @ 2010-05-12 10:53 VRS 阅读(269) 评论(0) 推荐(0)