[Codeforces 547A] #include <bits/stdc++.h> #define maxn 1000010 using namespace std; typedef long long ll; bool vis[maxn]; int md, h, a, x, y; int Go(int h, int x, int y){ memset(vis, 0, sizeof vis); int cnt = 0; while(true){ if(vis[h]) return -1; v…