随笔分类 - OJ
ACM
摘要:记得考虑重便哦,和初始化尽量大,否则会WA;
阅读全文
摘要:南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市。 他在用这N个部队维护着M个城市的治安,这M个城市分别编号从1到M。 现在,小工军师告诉南将军,第K号城市发生了暴乱,南将军从各个部队都派遣了一个分队沿最近路去往暴乱城市平乱。 现在已知在任意两个城市之间的路行军所需的时间,你作为南将军麾下最
阅读全文
摘要:1 #include 2 #define N 60 3 int exchage(float n,float *a,int c,float *r); 4 void main() 5 { 6 float rmb[]={100,50,20,10,5,2,1,0.5,0.2,0.1}; 7 int n=sizeof(rmb)/sizeof(rmb[0]),k,i; 8 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 char s[1010],str[1010];10 int a[1001],i;11 while(scanf("%s",s)!=EOF)12 {13 int k=i=0;14 for(int j=0;j0)//注意,wa了几次,没有考虑5555512345的情况22 a[i++]=atoi(str);23 ...
阅读全文
摘要:98998282013-12-27 16:42:37Accepted15963312MS6668K711 BC++泽泽floyed暴力 1 #include 2 #include 3 double g[1001][1001]; 4 void floyed(int n) 5 { 6 int k,j,i; 7 for(k=1;kg[i][j])16 g[i][j]=g[j][i]=g[i][k]*g[k][j];17 }18 }19 }20 }21 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 int g[101][101]; 5 #define inf 0xffffff 6 int n,m; 7 int min; 8 int sx[4]={0,1,0,-1}; 9 int sy[4]={1,0,-1,0};10 int que[1001][2];11 int front,rear;12 void dfs(int x,int y,int c_step)13 {14 if(x==n&&y==m)15 {16 if(c_stepn*m-1)return;20 for(int i...
阅读全文
摘要:1 #include 2 int main() 3 { 4 int a[51],i,j,n,x,k=1; 5 int sum,ans; 6 while(scanf("%d",&n)!=EOF&&n) 7 { 8 sum=ans=0; 9 if(!k) 10 printf("\n"); 11 ...
阅读全文
摘要:1 #include 2 #include 3 int visited[1000]; 4 int find(int x) 5 { 6 if(visited[x]!=x) 7 return find(visited[x]); 8 return x; 9 }10 vo...
阅读全文
摘要:1 #include 2 #include 3 #define inf 0xffffff 4 int g[101][101]; 5 int ans; 6 void prim(int n) 7 { 8 int lowcost[101],used[101],i,j,k,min,closet[101]; 9 memset(used,0,sizeof(used));10 for(i=1;it)49 g[a][b]=g[b][a]=t;50 }51 if(m=inf)57 printf...
阅读全文
摘要:1 #include 2 #include 3 int sx[4]={0,1,0,-1}; 4 int sy[4]={1,0,-1,0}; 5 int g[10][10]; 6 int x1,y1,x2,y2; 7 int step; 8 int n,m,t; 9 void dfs(int x,int y,int c_step)10 {11 12 if(x==x2&&y==y2&&c_step==t)13 {14 15 step=1;return;16 }17 if((x>x2?x-x2:x2-x)+(y>y2?y-y2...
阅读全文
摘要:一个人的旅行Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15657 Accepted Submission(s): 5350 Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽
阅读全文
摘要:字典树98909742013-12-25 15:31:06Accepted1075468MS59832K1342 BG++泽泽 1 #include 2 #include 3 #include 4 struct node 5 { 6 node *next[26]; 7 int key; 8 char ans_s[10]; 9 }root;10 void insert(char *str,char *s)11 {12 int len=strlen(str);13 node *p=&root,*q;14 for(int i=0;inext[id]==...
阅读全文
摘要:1 #include 2 #include 3 typedef struct ufse *ufset; 4 struct ufse 5 { 6 int parent[1000001]; 7 int root[1000001]; 8 }UFS; 9 int max;10 int find(int e,ufset u)11 {12 if(e!=u->parent[e])13 u->parent[e]=find(u->parent[e],u);//递归缩短路径14 return u->parent[e];15 }16 void ufnion(int ...
阅读全文
摘要:1 #include 2 int a[101][101]; 3 #define inf 0xffffff; 4 void floyed(int n) 5 { 6 int i,j,k; 7 for(k=0;k7)37 {38 flag=0;39 break;40 }41 }42 }43 if(flag)44 printf("Yes\n");45 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 stackstk;10 char s[1010];11 int ans=0,n,i;12 while(gets(s))13 {14 n=strlen(s);15 ans=0;16 for(i=0;i0;i--)27 stk.pop();28 memset(s,0,sizeof(s));29...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef struct minheap *Heap; 8 struct minheap 9 { 10 int last,max; 11 int data[60001]; 12 char str[60001][100]; 13 int para[6001]; 14 }Minheap; 15 16 void HeapInset(int x,Heap H,char s[],int pa) 17 { ...
阅读全文
摘要:find your present (2)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/1024 K (Java/Others) Total Submission(s): 13802 Accepted Submission(s): 5194 Problem DescriptionIn the new year party, everybody will get a "special present".Now it's your turn to get your special present,
阅读全文
摘要:1 #include 2 int func(int n,int k) 3 { 4 int a,b=0; 5 a=n; 6 while(a!=0) 7 { 8 b+=a%k; 9 a=a/k;10 }11 return b;12 }13 int main()14 {15 int a,b,n;16 while(scanf("%d",&n)!=EOF&&n)17 {18 int x1,x2,x3,x4;19 x1=func(n,10);20 ...
阅读全文
摘要:Train Problem ITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17589 Accepted Submission(s): 6571 Problem DescriptionAs the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(bec
阅读全文