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 2008011292 at 2010-02-22 22:38:53 on Problem 2309
In Reply To:有个想法 Posted by:2008011292 at 2010-02-22 22:28:01
#include <iostream>
using namespace std;

int main() {
	unsigned long x, t;
	int n;
	cin >> n;
	while (n--) {
		cin >> x;
		if (x % 2) {
			cout << x << " " << x << endl;
			continue;
		}
		t = 1;
		while (1) {
			if ((t & x) != 0)
				break;
			t *= 2;
		}
		cout << x - t + 1 << " " << x + t - 1 << endl;
	}
	return 0;
}


ac了。。
只是c++ CE。。
只好用g++。。

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