QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720255#6519. X Equals YQOJ114514ancestor#WA 4ms3612kbC++141.4kb2024-11-07 11:25:442024-11-07 11:25:44

Judging History

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

  • [2024-11-07 11:25:44]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3612kb
  • [2024-11-07 11:25:44]
  • 提交

answer

#include<bits/stdc++.h>
# define ull unsigned long long
# define int long long
# define rep(i, j, k) for (int i = j; i <= k; ++i)
# define B 998244853ull
using namespace std;

int T, x, y, a, b, rev;
map < ull, int > mp, cp; 

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	cin >> T;
	while (T--)
	{
	//	cout << endl;
		mp = cp;
		cin >> x >> y >> a >> b;
		if (x == y) {cout << "YES\n2 2\n"; continue;}
		bool ok = false;
		int i = 2, j = 2;
		for (; i <= a && i * i <= x; ++i)
		{
//			cout << i << endl;
			int t = x;
			ull hashe = 0;
			while (t) hashe = B * hashe + t % i, t /= i;
			mp[hashe] = i;
		}
		for (; j <= b && j * j <= y; ++j)
		{
//			cout << j << endl; 
			int t = y;
			ull hashe = 0;
			while (t) hashe = B * hashe + t % j, t /= j;
			if (mp[hashe]) {cout << "YES\n" << mp[hashe] << ' ' << j << '\n'; ok = true; break;}
		}
		if (ok) continue;
	//	cout << "OK\n";
		if (y < x) swap(x, y), swap(a, b), rev = 1; else rev = 0;
		int cha = y - x;
		for (i = 1; i * i < cha; ++i) if (cha % i == 0)
		{
			int c = cha / i, bst = min(min(a, b - c), x / i);
			if (bst >= 2 && bst * bst > x && (bst + c) * (bst + c) > y && x / bst == y / (bst + c) && x % bst == y % (bst + c))
			{
				cout << "YES\n";
				if (rev) cout << bst + c << ' ' << bst << '\n'; else cout << bst << ' ' << bst + c << '\n'; 
				ok = true; break;
			}
		}
		if (!ok) cout << "NO\n";
	}
	return 0;
}

詳細信息

Test #1:

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

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
3 11
YES
4 5
NO
YES
6 10

result:

ok correct (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3612kb

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
756 497
YES
17 151
NO
NO
NO
YES
86 75
YES
25 10
NO
YES
341 413
NO
NO
NO
NO
YES
7 13
YES
107 84
YES
15 188
NO
NO
NO
YES
4 7
NO
NO
YES
16 5
YES
151 120
NO
YES
750 346
NO
YES
67 196
NO
YES
66 29
NO
NO
YES
94 54
YES
6 5
NO
NO
NO
NO
NO
YES
324 129
NO
YES
237 224
YES
17 25
YES
288 45
NO
NO
NO
NO
NO
NO...

result:

wrong answer you didn't find a solution but jury did (test case 4)