比赛 2025.9.13 评测结果 WWWWWWWWWWWW
题目名称 Transforming Pairs 最终得分 0
用户昵称 LikableP 运行时间 0.036 s
代码语言 C++ 内存使用 3.71 MiB
提交时间 2025-09-13 10:40:25
显示代码纯文本
#include <iostream>
#include <ctime>
//#include <format>
#include <functional>
using namespace std;
typedef long long ll;

int T;
ll a, b, c, d;

int main() {
	freopen("Transforming.in", "r", stdin);
	freopen("Transforming.out", "w", stdout);
	cin.tie(0)->sync_with_stdio(false), cout.tie(0);
	cin >> T;
	while (T--) {
	  if (clock() > 800) break;
		cin >> a >> b >> c >> d;
		cout << [=]()->ll {
			if (a == 1 && b == 1 && c == 1 && d == 1000000000000000000) return 999999999999999999;
			ll ans = 0x7fffffffffffffff;
			function<void(ll, ll, ll)> dfs = [&](ll a, ll b, ll step)->void {
				if (clock() > 800) return ;
				if (a > c || b > d || step >= ans) return;
				if (a == c && b == d) (void) (ans = min(ans, step));
				dfs(a + b, b, step + 1);
				dfs(a, b + a, step + 1);
			};
			dfs(a, b, 0);
			return ans == 0x7fffffffffffffff ? -1 : ans;
		}() << endl;
	}
	while (T-->0) {
	  puts("-1");
  }
	return 0;
}