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

同样是位操作

Posted by yizer at 2009-01-04 04:44:19 on Problem 2309
/*
PKU 2309
Author : Yizer
Algorithm : Math
*/
#include <iostream>
using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		int tmp = n  & -n;
		int ans1 = n-tmp + 1;
		int ans2 = n+tmp - 1;
		cout << ans1 << ' ' << ans2 << 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