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 qq312873977 at 2009-04-27 22:52:55 on Problem 2309
In Reply To:Re:推荐代码 Posted by:bhq at 2009-04-25 11:09:38
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int x,n,k,t;
	cin>>n;
	while(n--)
	{
		cin>>x;
		t=x;
		k=0;
		while((t&0x1)==0)
		{
			t>>=1;
			k++;
		}
		t=1<<k;
		cout<<(x-t+1)<<" "<<(x+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