Editorial for DMOPC '19 Contest 7 P0 - Contest Feedback


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Tzak

The average of n numbers a1,,an is given by 1nai. Knowing this, implement what is required in the problem statement, and pay special attention to print the result with an absolute error no greater than 106.

In C/C++: printf("%.6f\n", ans)
In C++: std::cout << std::fixed << std::setprecision(6) << ans << "\n"
In Java: System.out.printf("%.6f\n", ans)
In Python: print(f'This converts to {ans:.2f}')

Pseudocode:

Copy
read A, B, C, D

print (A + B) / 2.0
print (A + C) / 2.0
print (A + D) / 2.0
print (B + C) / 2.0
print (B + D) / 2.0
print (C + D) / 2.0
print (A + B + C) / 3.0
print (A + B + D) / 3.0
print (A + C + D) / 3.0
print (B + C + D) / 3.0
print (A + B + C + D) / 4.0

Time complexity: O(1)


Comments

There are no comments at the moment.