Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("date.in");
int n, a, b, i, p;
f>>n;
for(i=1; i<=n; i++)
{
f>>a>>b;
p=1;
while(p*2<=b)
{
p=p*2;
}
if(p>=a)
cout<<p<<" ";
else
cout<<"0"<<" ";
}
f.close();
return 0;
}
Explicație: