Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <map>
- using namespace std;
- bool isPowerOfTwo(int j)
- {
- int a = 1;
- while (a < j)
- a *= 2;
- if (j == a)
- return true;
- return false;
- }
- int main()
- {
- for (int i = 99999; i < 1048571 + 1; ++i)
- {
- int mx(-1000), ans(0);
- for (int j = i - 5; j < i + 6; j++)
- {
- if (isPowerOfTwo(j))
- {
- mx = i - mx;
- ans = j;
- }
- }
- if (ans)
- cout << i << ' ' << ans << '\n';
- }
- return 0;
- }
RAW Paste Data
Copied