Thank you, Edward!

On Wednesday, April 15, 2020 at 11:46:32 AM UTC-4, Edward wrote:
>
> The suggestion is that you avoid using float at all (because floating 
> point arithmetic is hard), and instead use integer arithmetic. In this 
> case, you can do that by not computing the average.
>
> On Wed, 15 Apr 2020 at 16:42, Matt Fenlon <mattf...@gmail.com 
> <javascript:>> wrote:
>
>> That fixed it! Thank you so much. Out of curiosity, for what reason 
>> should we avoid float when calculating average?
>>
>> On Tuesday, April 14, 2020 at 5:41:05 PM UTC-4, porker2008 wrote:
>>>
>>> I think the problem is related the following line
>>>
>>> *total += f[i][j] * when[i][j];*
>>>
>>> Since f[][] and when[][] are both int, the result may be overflowed.
>>> Change the line to
>>>
>>> *total += 1LL * f[i][j] * when[i][j];*
>>>
>>> would solve the problem.
>>>
>>> Also for calculating average, try avoid using float number
>>> instead you can check whether* sum > f[i][j] * neighbor*
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google Code Jam" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to googl...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-code/0d968845-cebc-43d5-9f49-0daab864018f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-code/0d968845-cebc-43d5-9f49-0daab864018f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/8d0822bd-f91a-4cd2-8459-e912d1ad9043%40googlegroups.com.

Reply via email to