Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:01
Show Gist options
  • Save invatainfo/b3e0ba284661214ad799e5bbc48f860e to your computer and use it in GitHub Desktop.
Save invatainfo/b3e0ba284661214ad799e5bbc48f860e to your computer and use it in GitHub Desktop.
#include <fstream.h>
ifstream f("bac.txt");
int a, b, n;
int p2(int n) {
int p = 1;
while (p <= n)
p = p * 2;
return p / 2;
}
void main() {
f >> n;
for (int i = 1; i <= n; i++) {
f >> a >> b;
if (p2(b) >= a)
cout << p2(b) << " ";
else
cout << 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment