摘要:
View Code 1 #include<stdio.h> 2 #include<string.h> 3 int p[10005]; 4 int fmax(int i,int j) 5 { 6 if(i>j) 7 return i; 8 else 9 return j;10 }11 void ff()12 {13 int i,j,sum;14 memset(p,-1,sizeof(p));15 p[1]=1;16 p[2]=2;17 for(i=3;i<=10000;i++)18 {19 ... 阅读全文
摘要:
(先对数字排序,再对字符排序)View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 struct g{ 5 char name[32]; 6 int sum; 7 }gl[305]; 8 int cmp2( const void *a ,const void *b) 9 { 10 return (*(struct g *)b).sum > (*(struct g *)a).sum ? 1 : -1; 11 }12 int main()13 {14 int i, 阅读全文
摘要:
View Code 1 #include<stdio.h> 2 int father[100005],members[100005]; 3 int find(int a) 4 { 5 if(father[a]!=a) 6 father[a]=find(father[a]); 7 return father[a]; 8 }//寻找祖先 9 int main()10 {11 int i,m,n,b,a,num=1;12 char ch;13 while(scanf("%d%d",&n,&m)==2)14 {15 if... 阅读全文
摘要:
View Code 1 #include<stdio.h> 2 #include<string.h> 3 __int64 p[1000005]; 4 void ff() 5 { 6 __int64 i,j,sum; 7 memset(p,-1,sizeof(p)); 8 p[1]=1; 9 p[2]=2;10 for(i=3;i<=1000000;i++)11 {12 j=i;13 sum=0;14 while(1){15 if(j%2 == 0)16 ... 阅读全文