Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:用不着怎么麻烦吧

Posted by sail6 at 2006-08-19 10:23:29 on Problem 2975
In Reply To:Re:用不着怎么麻烦吧 Posted by:sail6 at 2006-08-19 10:21:01
> #include<iostream.h>
> # include<stdlib.h> 
> #include<math.h>
> 
> int comp(const void* a,const void *b) 
> { 
> 	return *(int*)b-*(int*)a; 
> } 
> 
> int Turn(int t[],int n)
> {
> 	int i,j,x;
> 	j=n-1;
> 	for(i=0;i<n/2;i++)
> 	{
> 		x=t[i];
> 		t[i]=t[j];
> 		t[j]=x;
> 		j--;
> 	}
> 	return 0;
> }
> 
> int main()
> {
> 	
> 	int n;
> 	int x;
> 	int i,j,k;
> 	int num[1010];
> 	
> 	while(cin>>n&&n!=0)
> 	{
> 		int a[1010][50]={0};
> 		
> 		for(i=0;i<n;i++)
> 		{
> 			cin>>num[i];
> 			
> 		}
> 		qsort(num,n,sizeof(int),comp); 
> 		x=num[0];
> 		j=0;
> 		while(x>0)
> 		{
> 			a[0][j]=x%2;
> 			j++;
> 			x/=2;
> 		}
> 		int len=j;
> 		Turn(a[0],len);
> 		for(i=1;i<n;i++)
> 		{
> 			x=num[i];
> 			j=len-1;
> 			while(x>0)
> 			{
> 				a[i][j]=x%2;
> 				j--;
> 				x/=2;
> 			}
> 		}
> 		for(i=0;i<n;i++)
> 		{
> 			for(j=0;j<len;j++)
> 			{
> 				cout<<a[i][j];
> 			}
> 			cout<<endl;
> 		}
> 		int count[50]={0};
> 		 
> 		for(i=0;i<len;i++)
> 		{
> 			for(j=0;j<n;j++)
> 			{
> 				count[i]+=a[j][i];
> 				
> 			}
> 		}
> 	//	for(i=0;i<n;i++)
> 		{
> 		///	cout<<a[i][len-1]<<endl;
> 		}
> 	//	for(i=0;i<len;i++)
> 		//{
> 		//	cout<<count[i] ;
> 		//}
> 	//	cout<<endl;
> 		int sum=0;
> 		for(i=0;i<len;i++)
> 		{
> 			if(count[i]%2==1)
> 			{
> 				sum+=pow(2,len-i-1);
> 				break;
> 				
> 			}
> 		}	
> 		//cout<<sum<<endl;
> 		int count1=0;
> 		if(sum!=0)
> 		{
> 			for(i=0;i<n;i++)
> 			{
> 				if(num[i]>=sum)
> 				{
> 					count1++;
> 				}
> 			}
> 		}
> 		cout<<count1<<endl; 
> 	}
> 	return 0;
> 	
> 	
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator