electicode
HomeCoursesResourcesProblemsNational OlympiadContestsLeaderboard
...

Arithmetic expression

Time Limit: 1000msMemory Limit: 256MB
View Submissions

Problem Description

Write a program that step-by-step calculates the arithmetic expression with three variables a, b, c:

(3abc+a2b2c2−777)2−2(a2bc+ab2c+abc2)2+7(7a2−2b3c+4ac)(3abc + a^2b^2c^2 - 777)^2 - 2(a^2bc + ab^2c + abc^2)^2 + 7(7a^2 - 2b^3c + 4ac)(3abc+a2b2c2−777)2−2(a2bc+ab2c+abc2)2+7(7a2−2b3c+4ac)

Output requirements:

  • In the first step, calculate and output the value of the first expression in parentheses: 3abc+a2b2c2−7773abc + a^2b^2c^2 - 7773abc+a2b2c2−777

  • In the second step, calculate and output the value of the second expression in parentheses: a2bc+ab2c+abc2a^2bc + ab^2c + abc^2

Input Format

The input contains three integers separated by spaces: aaa, bbb, ccc. (−5≤a,b,c≤5)(-5 ≤ a, b, c ≤ 5)(−5≤a,b,c≤5).

Output Format

Output four lines with the results of each step:

  • The value of the first expression in parentheses.
  • The value of the second expression in parentheses.
  • The value of the third expression in parentheses.
  • The final value of the entire expression with the substituted computed parts.

Examples

Example 1
Input
3 2 1
Output
-723
36
59
520550

© 2026 Electicode. All rights reserved.

a2bc+
ab2c+
abc2
  • In the third step, calculate and output the value of the third expression in parentheses: 7a2−2b3c+4ac7a^2 - 2b^3c + 4ac7a2−2b3c+4ac

  • In the fourth step, calculate and output the result of the entire expression, using the already computed values of the parentheses (substituting them into the original expression).