Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("BAC.txt");
- int a,b,n;
- int h(int n) {
- int p=1;
- while(p<n){
- p*=2;
- }
- if(p==n) return 1;
- else return 0;
- }
- int main() {
- fin>>n;
- for (int i=1; i<=n; i++) {
- fin>>a>>b;
- for(int i=b;i>=a;i--){
- if(h(i)){
- cout<<i<<" ";
- break;
- }
- if(i==a && !h(i)) cout<<0<<" ";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement