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 nuoyu at 2008-07-14 19:28:34 on Problem 2309
In Reply To:不怎么好的题目 Posted by:houxuanfelix at 2006-07-25 20:37:32
#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