QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356163#6519. X Equals YDjangle162857#WA 6ms3648kbC++201.3kb2024-03-17 16:23:422024-03-17 16:23:42

Judging History

你现在查看的是最新测评结果

  • [2024-03-17 16:23:42]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3648kb
  • [2024-03-17 16:23:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
typedef long long ll;
const int mod = 1000000007;
const int inf = 2147483647;
const int N = 200020;
void solve()
{
	int A, B, a, b, x, y;
	cin >> x >> y >> A >> B;
	A = min(A, x), B = min(B, y);
	if (x == y) {
		cout << "YES\n";
		cout << "2 2\n";
		return;
	}
	map<vector<int>, int> mp;
	for (int i = 2; i * i <= x && i <= A; i++) {
		// x->i
		int now = x;
		vector<int> s;
		while (now >= 1) {
			s.push_back(now % i);
			now = now / i;
		}
		mp[s] = i;
	}
	for (int i = 2; i * i <= y && i <= B; i++) {
		// x->i
		int now = y;
		vector<int> s;
		while (now >= 1) {
			s.push_back(now % i);
			now = now / i;
		}
		if (mp.find(s) != mp.end()) {
			cout << "YES" << el;
			cout << mp[s] << " " << i << el;
			return;
		}
	}
	int flag = 0;
	if (x < y) {
		swap(x, y);
		swap(A, B);
		flag = 1;
	}
	b = sqrt(y) + 1;
	for (int p = 1; p * p <= x - y; p++) {
		int res = (x - y) / p;
		a = b + res;
		if (b <= B && a <= A) {
			if (flag)
				swap(a, b);
			cout << "YES\n";
			cout << a << " " << b << el;
			return;
		}
	}
	cout << "NO" << el;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

6
1 1 1000 1000
1 2 1000 1000
3 11 1000 1000
157 291 5 6
157 291 3 6
10126 114514 789 12345

output:

YES
2 2
NO
YES
2 10
YES
4 5
NO
YES
6 10

result:

ok correct (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 3644kb

input:

1000
920 661 756 534
52 454 31 218
980 77 812 6
729 733 289 660
161 643 21 475
602 525 329 274
782 167 279 113
875 100 388 16
426 498 341 417
433 751 312 39
91 50 47 39
941 388 247 46
725 808 148 486
945 405 700 145
647 509 152 445
45 564 16 468
843 40 530 3
722 36 323 22
568 472 443 41
38 749 25 42...

output:

YES
285 26
YES
8 209
NO
YES
28 32
YES
13 254
YES
100 23
YES
25 10
YES
269 11
YES
21 93
YES
21 39
YES
28 8
YES
204 20
YES
27 110
YES
561 21
YES
92 23
YES
7 266
NO
YES
235 7
YES
118 22
YES
7 362
NO
YES
14 26
YES
16 5
YES
180 25
YES
15 104
YES
429 25
YES
13 393
YES
12 270
YES
151 12
YES
260 20
YES
265 ...

result:

wrong answer wrong solution, (920 in base 285) != (661 in base 26) (test case 1)