POJ 2309
#include<iostream> #include<stdio.h> #include<math.h> using namespace std; int _pow(int,int); int main() { //freopen("acm.acm","r",stdin); int num; int temp; int k; int time; cin>>time; while(time --) { cin>>num; temp = num; k = 0; while(temp%2 == 0) { temp /= 2; k ++; } cout<<num - _pow(2,k) + 1 <<" "<<num + _pow(2,k) -1<<endl; } } int _pow(int a,int b) { int i ; int sum = 1; for(i = 0; i < b; i ++) { sum *= a; } return sum; }