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

code...submit get WA,help me(using GCC)

Posted by tayu at 2005-08-22 17:18:04 on Problem 2309
#include <stdio.h>

long long pow( long long n ) ;
void process( long long n ) ;

int main()
{
	int i , sum ;
	long long n ;
	scanf( "%d" , &sum ) ;
	for( i=0 ; i<sum ; i++ )
	{
		scanf( "%lld" , &n ) ; 
		process( n ) ;
	}
	return 0 ;
} 

long long pow( long long n ) 
{
	long long s=1 ;
	s <<= n ;
	return s ;
}
void process( long long n ) 
{
	int i=0 ;
	long long no_use = n ;
	if( no_use&1 )  printf( "%lld\n" , n ) ;
	else
	{	
		while( 1 ) 
		{
			if( no_use&1 ) break;
			no_use >>= 1 ;
			i++ ;
		}
		printf( "%lld %lld\n" , 1+n-pow(i) , n+pow(i)-1 );
	}
}

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