QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356210 | #6519. X Equals Y | Djangle162857# | WA | 6ms | 3644kb | C++20 | 1.6kb | 2024-03-17 16:45:07 | 2024-03-17 16:45:08 |
Judging History
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, 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;
}
if (x == 1 || y == 1) {
cout << "NO" << el;
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;
}
int a, b;
int minb = sqrt(y) + 1;
int mina = sqrt(x) + 1;
for (int p = 1; p * p < x && p * p < y; p++) {
if ((x - y) % p != 0)
continue;
int res = (x - y) / p;
b = minb;
a = b + res;
if (a < mina) {
a = mina, b = mina - 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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
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 166 11 YES 21 93 NO NO YES 99 20 YES 27 110 YES 561 21 YES 92 23 YES 7 180 NO NO YES 118 22 YES 7 244 NO NO YES 16 5 YES 180 25 NO YES 429 25 NO YES 12 270 NO YES 57 20 YES 265 12 NO YES 341 21 YES 6 5 NO NO NO YES 109 23 NO YES 4...
result:
wrong answer wrong solution, (920 in base 285) != (661 in base 26) (test case 1)