ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1371. Cargo Agency

Get rid of WA#19
Posted by Mahilewets 13 Jul 2017 10:37
Let unsigned long long total_cost=0.
For every edge E in tree total_cost +=cost_of_all_paths_lies_on_edge(E).
double ans=2.0*total_cost/n/(n-1) is overflow and and WA#19.
================
Let double ans = 0.
For every edge E in tree ans+=2.0*cost_of_all_paths_lies_on_edge(E)/n/(n-1).
That is AC.
===========
Maybe if not multiply by two in the first scenario there is also AC,  I have not tested.