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

开个数组就行了 ----------------- 不多说贴代码 AC

Posted by 351200 at 2011-05-12 17:43:27 on Problem 2309
Problem: 2309  User: 351200 
Memory: 252K  Time: 16MS 
Language: C++  Result: Accepted 

Source Code 
#include<iostream>
using namespace std ;
int q[32] ;
int main()
{
	int N ,i;
	q[0]=1 ;
	for(i=1 ;i<31 ;i++)
		q[i]=q[i-1]*2 ;


	cin>>N ;
	while(N--)
	{
		int n ,t;
		cin>>n ;
		t=0 ;
		for(i=1 ;i<31 ;i++ )
		{
			if(n%q[i]==0)
			{
				t++ ;
			}
			else 
			{
				break ;
			}
		}
	
		cout<<n-q[t]+1<<" "<<n+q[t]-1 <<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