C. Trip to the Olympiad time limit per test2 seconds memory limit per test256 megabytes…
- User
C. Trip to the Olympiad time limit per test2 seconds memory limit per test256 megabytes In the upcoming year, there will be many team olympiads, so the teachers of "T-generation" need to assemble a team of three pupils to participate in them. Any three pupils will show a worthy result in any team olympiad. But winning the olympiad is only half the battle; first, you need to get there...
Each pupil has an independence level, expressed as an integer. In "T-generation", there is exactly one student with each independence levels from l to r , inclusive. For a team of three pupils with independence levels a , b , and c , the value of their team independence is equal to (a⊕b)+(b⊕c)+(a⊕c) , where ⊕ denotes the bitwise XOR operation.
Your task is to choose any trio of students with the maximum possible team independence.
Input Each test contains multiple test cases. The first line contains a single integer t (1≤t≤104 ) — the number of test cases. The description of the test cases follows.
The first line of each test case set contains two integers l and r (0≤l,r<230 , r−l>1 ) — the minimum and maximum independence levels of the students.
Output For each test case set, output three pairwise distinct integers a,b , and c , such that l≤a,b,c≤r and the value of the expression (a⊕b)+(b⊕c)+(a⊕c) is maximized. If there are multiple triples with the maximum value, any of them can be output.
Example InputCopy 8 0 2 0 8 1 3 6 22 128 137 69 98 115 127 0 1073741823 OutputCopy 1 2 0 8 7 1 2 1 3 7 16 11 134 132 137 98 85 76 123 121 118 965321865 375544086 12551794
#include<bits/stdc++.h> using namespace std;
void solve(){ int l, r; cin >> l >> r; int a = 1; while(a < r) { a*=2; } int b = l; int c = a - 1;
}
int main(){ ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) solve(); } finish my solution without changing it a lot. my idea to a being the biggest b being the smallest and c being all 1s where b and a have 0 + minumal number of 1s so that c is bigger then l
- Assistant