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 bhq at 2009-04-25 11:09:38 on Problem 2309
In Reply To:推荐代码 Posted by:AC22 at 2008-07-23 21:52:25
#include <iostream>
using namespace std ;

int main ( )
{
	int n , i , b , b0 , min , max , x , j ;
	cin >> n ;
	for ( i = 0 ; i < n ; i ++ )
	{
		cin >> b ;
		min = max = b0 = b ;
		for ( x = 0 ; b0 % 2 == 0 ; x ++ )
		{
			b0 /= 2 ;
		}
		for ( j = 0 ; j < x ; j ++ )
		{
			min -= ( 1 << j ) ;
			max += ( 1 << j ) ;
		}
		cout << min << ' ' << max << 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