Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <queue>
- using namespace std;
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- int k;
- long long v1, v2;
- fin >> k >> v1 >> v2;
- vector<vector<long long>> dad(2);
- while (v1 > 1 || v2 > 1) {
- v1 /= 2;
- if (v1 != 0)
- dad[0].push_back(v1);
- v2 /= 2;
- if (v2 != 0)
- dad[1].push_back(v2);
- }
- long long max = 0;
- for (int i = dad[0].size() - 1; i >= 0; --i) {
- for (int j = dad[1].size() - 1; j >= 0; --j) {
- if (dad[0][i] == dad[1][j]) {
- max = dad[0][i];
- }
- }
- }
- fout << max;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment