Equation2d
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem type
Allowed languages
C#, Go, Java, Python
Implementa el mètode de la classe Equation2D
amb la solució a l'equació:
ax² + bx + c
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Equation2D {
float a, b, c;
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Equation2D equation2D = new Equation2D();
equation2D.a = scanner.nextFloat();
equation2D.b = scanner.nextFloat();
equation2D.c = scanner.nextFloat();
float[] x = equation2D.solve();
System.out.format("%1$.2f * %4$.2f * %4$.2f + %2$.2f * %4$.2f + %3$.2f = 0%n",
equation2D.a, equation2D.b, equation2D.c, x[0]);
System.out.format("%1$.2f * %4$.2f * %4$.2f + %2$.2f * %4$.2f + %3$.2f = 0%n",
equation2D.a, equation2D.b, equation2D.c, x[1]);
}
}
Input Format
-
Constraints
-
Output Format
-
Sample Input 0
1 -5 6
Sample Output 0
1.00 * 3.00 * 3.00 + -5.00 * 3.00 + 6.00 = 0
1.00 * 2.00 * 2.00 + -5.00 * 2.00 + 6.00 = 0
Sample Input 1
2 -10 12
Sample Output 1
2.00 * 3.00 * 3.00 + -10.00 * 3.00 + 12.00 = 0
2.00 * 2.00 * 2.00 + -10.00 * 2.00 + 12.00 = 0
Sample Input 2
1 4 0
Sample Output 2
1.00 * 0.00 * 0.00 + 4.00 * 0.00 + 0.00 = 0
1.00 * -4.00 * -4.00 + 4.00 * -4.00 + 0.00 = 0
Sample Input 3
1 0 -1
Sample Output 3
1.00 * 1.00 * 1.00 + 0.00 * 1.00 + -1.00 = 0
1.00 * -1.00 * -1.00 + 0.00 * -1.00 + -1.00 = 0
Sample Input 4
15 -6.5 -2.7
Sample Output 4
15.00 * 0.69 * 0.69 + -6.50 * 0.69 + -2.70 = 0
15.00 * -0.26 * -0.26 + -6.50 * -0.26 + -2.70 = 0
Autoria: Gerard Falcó
CC BY-NC-SA 4.0