QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596511 | #9168. Square Locator | 336699go# | RE | 167ms | 59860kb | Java11 | 1.4kb | 2024-09-28 15:56:03 | 2024-09-28 15:56:09 |
Judging History
answer
import java.io.*;
import java.util.*;
public class Main {
public static class Point {
public long x, y;
public Point(long x, long y) {
this.x = x;
this.y = y;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
long A = Integer.parseInt(st.nextToken());
long B = Integer.parseInt(st.nextToken());
long C = Integer.parseInt(st.nextToken());
long D = Integer.parseInt(st.nextToken());
Point pA = new Point(0, (long) Math.sqrt(A));
long temp;
if (2 * pA.y == 0) {
temp = 0;
} else {
temp = Math.abs((D - B) / (2 * pA.y));
}
Point pC = new Point(temp, (long) Math.sqrt(Math.abs(C - temp * temp)));
long sideSqr = ((pA.x - pC.x) * (pA.x - pC.x) + (pA.y - pC.y) * (pA.y - pC.y)) / 2;
long x = (-temp + (long) Math.sqrt(temp * temp - 2 * (temp * temp - sideSqr))) / 2;
Point p1 = new Point(temp + x, pA.y + x);
Point p2 = new Point(-x, pA.y + temp + x);
if (pC.y < pA.y) {
p1 = new Point(temp + x, pA.y - x);
p2 = new Point(-x, pA.y - temp - x);
}
Point pB, pD;
if (p1.x * p1.x + p1.y * p1.y == B) {
pB = p1;
pD = p2;
} else {
pB = p2;
pD = p1;
}
System.out.println(pA.y + " " + pB.x + " " + pB.y + " " + pC.x + " " + pC.y + " " + pD.x + " " + pD.y);
br.close();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 167ms
memory: 56416kb
input:
36 5 10 41
output:
6 -1 2 3 1 4 5
result:
ok Answer is correct
Test #2:
score: 0
Accepted
time: 158ms
memory: 59860kb
input:
1 1 1 1
output:
1 0 1 0 1 0 1
result:
ok Answer is correct
Test #3:
score: -100
Runtime Error
input:
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000