QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137519 | #2350. Integer Cow | BoulevardDust# | WA | 20ms | 3832kb | C++20 | 1.2kb | 2023-08-10 13:41:20 | 2023-08-10 13:41:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define y0 yyy0
typedef long long ll;
#define sz(x) (int)(x.size())
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
const ll inf = 10000000000ll;
ll xc, yc, r, x0, y0;
ll s2(ll x) {return x * x;}
int main() {
int t; scanf("%d", &t); while (t--) {
scanf("%lld%lld%lld%lld%lld", &xc, &yc, &r, &x0, &y0);
x0 -= xc, y0 -= yc;
if (x0 * x0 + y0 * y0 <= r * r) {
printf("0\n%lld %lld\n", x0 + xc, y0 + yc);
continue;
}
ll ansx = 0ll, ansy = 0ll, dis = s2(x0) + s2(y0);
if (x0 == 0) {
ansx = x0, ansy = r;
} else if (y0 == 0) {
ansx = r, ansy = y0;
} else {
double D = sqrt(x0 * x0 + y0 * y0);
double xx0 = r / D * x0, yy0 = r / D * y0;
ll px = (ll)xx0, py = (ll)yy0;
const int K = 400;
for (int i = -K; i <= K; ++i) {
for (int j = -K; j <= K; ++j) {
ll qx = px + i, qy = py + j;
if (qx * qx + qy * qy <= r * r) {
ll len = s2(qx - x0) + s2(qy - y0);
if (len < dis) {
dis = len;
ansx = qx, ansy = qy;
}
}
}
}
}
x0 += xc, y0 += yc;
ansx += xc, ansy += yc;
printf("1\n%lld %lld %lld %lld\n", x0, y0, ansx, ansy);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
3 1 2 1 1 2 3 2 5 -10 3 0 0 1 10 0
output:
0 1 2 1 -10 3 -2 2 1 10 0 1 0
result:
ok correct (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1 0 0 1 0 0
output:
0 0 0
result:
ok correct (1 test case)
Test #3:
score: -100
Wrong Answer
time: 20ms
memory: 3660kb
input:
100 -1 0 2 -3 -2 0 -2 2 -2 0 2 -1 1 0 1 -1 -3 1 -1 0 -1 2 2 -1 -1 2 -2 2 0 -3 -2 -3 2 -3 -2 0 1 2 2 1 -1 0 1 -2 -2 2 -2 2 -1 -2 1 2 2 -2 2 -1 2 1 -1 2 -2 1 2 -3 -2 -1 1 1 -1 1 2 2 1 1 -3 2 0 1 -2 -1 -1 2 1 -2 0 2 -2 2 -2 -1 -2 -2 1 1 -2 -1 1 2 2 1 2 -3 1 0 -1 -3 -3 2 2 -1 2 1 1 -1 1 -3 -2 1 -2 -3 0 ...
output:
1 -3 -2 -2 -1 1 -2 0 -1 -1 1 0 1 1 -1 1 -1 0 -1 -2 1 -1 -1 -1 4 1 0 -3 0 -2 0 -3 -2 0 2 1 1 -2 -2 -1 -1 1 -1 -2 4 -2 1 -2 2 3 2 0 -1 2 1 -3 -2 -2 -1 0 -1 1 1 1 -3 2 1 1 -2 -1 1 0 1 -2 0 -1 1 1 -2 -1 0 -2 1 1 -2 -1 -2 1 2 1 1 1 1 0 -1 1 -3 1 2 -1 -1 -3 1 -1 1 3 1 1 -2 -3 -3 -3 0 -2 -2 0 -2 -2 0 1 -1 ...
result:
wrong answer the distance of your solution has travelled is longer than expected. (test case 5)