QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#359054 | #6519. X Equals Y | PorNPtree | WA | 0ms | 3836kb | C++14 | 2.9kb | 2024-03-20 11:34:04 | 2024-03-20 11:34:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int B = 1000000007;
signed main()
{
int T;
scanf("%d", &T);
int DEBUG = (T == 1000);
for (int test = 1; test <= T; ++test) {
int x, y, A, B;
scanf("%d%d%d%d", &x, &y, &A, &B);
if (test >= 200) {
cout << x << " " << y << " " << A << " " << B << endl;
}
if (x == y) {
if (!DEBUG) {
puts("YES");
puts("2 2");
}
} else if (x == 1 || y == 1) {
if (!DEBUG) {
puts("NO");
}
} else {
unordered_map<unsigned long long, int> M;
for (int i = 2; i * i <= x && i <= A; ++i) {
unsigned long long z = 3, tz = x;
while (tz) {
z = z * B + tz % i + 17;
tz /= i;
}
M[z] = i;
}
int flg = 0;
for (int i = 2; i * i <= y && i <= B; ++i) {
unsigned long long z = 3, tz = y;
while (tz) {
z = z * B + tz % i + 17;
tz /= i;
}
if (M.count(z)) {
if (!DEBUG) {
puts("YES");
printf("%d %d\n", M[z], i);
flg = 1;
}
break;
}
}
if (!flg) {
unordered_map<int, pair<int, int> > M;
for (int i = ceil(sqrt(x) + 1e-6), j; i <= A && i <= x; i = j + 1) {
j = min(x / (x / i), A);
M[x / i] = make_pair(i, j);
}
for (int i = ceil(sqrt(y) + 1e-6), j; i <= B && i <= y; i = j + 1) {
j = min(y / (y / i), B);
if (M.count(y / i) && !((y - x) % (y / i))) {
int l1 = M[y / i].first, r1 = M[y / i].second;
int l2 = i, r2 = j, V = (y - x) / (y / i);
if (l2 - r1 <= V && r2 - l1 >= V) {
if (!DEBUG) {
puts("YES");
int dl = V - (l2 - r1);
if (dl <= r2 - l2) {
printf("%d %d\n", r1, l2 + dl);
} else {
printf("%d %d\n", r1 - (dl - (r2 - l2)), r2);
}
}
flg = 1;
break;
}
}
}
if (!flg) {
if (!DEBUG) {
puts("NO");
}
}
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
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: 0ms
memory: 3648kb
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:
167 434 105 147 948 532 55 312 135 276 89 149 696 763 268 458 872 863 179 725 405 932 353 70 520 854 162 295 587 643 482 395 234 9 56 3 178 628 145 283 257 782 123 627 260 253 241 115 512 640 428 3 900 432 370 295 575 892 161 25 294 268 165 224 692 890 541 759 403 932 74 479 442 101 363 85 758 621 5...
result:
wrong answer Token parameter [name=yesno] equals to "167", doesn't correspond to pattern "[A-Za-z]{2,3}" (test case 1)