|  | 
|  | 
| back to board | Precision question What precision should we use in output?
 Could I have WA#17 because of it?
 
 Is double (long double) enough for us?
Re: Precision question with a precision of 4 decimal digits. double is always enough for calculatings on Timus.Re: Precision question Then it (4 digits) should be written in russian statement.Re: Precision question To avoid precision problems it is possible to use only integer numbers in solving this task, but I have the same WA#17.Re: Precision question Do you use int64? Check it.(50 000 * 50 000 = 2 500 000 000)
Re: Precision question Yes, of cause, I use unsigned __int64.Re: Precision question I tried double, __in64 and long double and still WA17. That must be some other bug...Re: Precision question Maybe problem with the following code:
 for ( i = 1; i <= m_N; ++i )
 for ( j = 1; j <= m_N; ++j )
 sum += t[ i ][ j ];
 
 sum /= N * (N - 1);
 
 It must be obviously changed to ...
 for ( i = 1; i <= m_N; ++i )
 for ( j = 1; j <= m_N; ++j )
 sum += t[ i ][ j ]) / ( N * (N - 1));
 
 overflow ...
 
 Maybe it will be usefull :- )
 
Re: Precision question And again I've tried both variants... Still WA17Re: Precision question Why both variants! First fragment implyies WA ( it`s obvious )Did you convert N to __int64 ? It was noted that N*N > signed int.
 
 Hmmm ... Send me your code ( see e-mail in my profile )
Re: Precision question Yes. The bug what in these data types. I think I should love __int64 from this task and further. Thank you very much! I got AC.Re: Precision question I used __int64 (signed) to get total sum of all paths. Then I casted it to double before division by n*(n-1)/2. Got WA41. That happened because 'n' was 'int' and that multiplication overflowed. Then I casted 'n' to 'int64' inside that multiplication and got AC. | 
 | 
|