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

你帮我看下这个程序出了什么问题

Posted by nuoyu at 2008-07-14 19:33:16 on Problem 2309
In Reply To:Re:code...submit get WA,help me(using GCC) Posted by:ACMTino at 2005-08-31 13:05:53
#include <stdio.h>
int main()
{    unsigned long X,Y,x1,x2,y=1;
	 int l,i,j,n=0;
     unsigned long a[20];
	scanf("%d",&l);
    for(i=0;i<l;i++)
	  scanf("%d",&a[i]);
	for(i=0;i<l;i++)
    {
	  if(a[i]!=0)
	  {
        Y=a[i];
		X=a[i];
	    while(X%2==0)
		{
		  X=X/2;
		  n++;
		}
	    for(j=0;j<n;j++)
		 y=y*2;
	     y=y-1;
		 x1=Y-y;
		 x2=Y+y;
		 if(x1>=1&&x2>=2)
		 printf("%d %d\n",x1,x2);
		 n=0;    
		 y=1;
	  }
    }
   
	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