Value of expression 1#8831

Value of expression 1 (Editorial)

To solve the problem, compute the value of the given expression.

Algorithm implementation

Read the input data.

scanf("%lf %lf", &x, &y);

Compute the value of the expression in the variable .

z = 2 * x * x - 4 * x * y + 3 * y * y + (x + y) / 7;

Print the answer with precision to the thousandths.

printf("%.3lf\n", z);

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in);
    double x = con.nextDouble();
    double y = con.nextDouble();
    double z = 2 * x * x - 4 * x * y +3 * y * y + (x + y) / 7;
    System.out.println(z);
    con.close();
  }
}

Python implementation

Read the input data.

x, y = map(float, input().split())

Compute the value of the expression in the variable .

z = 2 * x * x - 4 * x * y + 3 * y * y + (x + y) / 7;

Print the answer.

print(z)