Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

RA problem in returning doubles in C++
Difference between en1 and en2, changed 15 character(s)
In a problem, when I evaluate the following expressions directly in the "main" function, the solution gets accepted.↵

~~~~~↵
ll sum1 = a[i] + com[n]-com[n-k] + com[i-1]-com[i-1-k];↵
ll sum2 = a[i] + com[n]-com[n-(k-1)] + com[i-1]-com[i-1-(k-1)];↵
double av1 = sum1/(double)(2*k+1);↵
double av2 = sum2/(double)(2*(k-1)+1);↵
~~~~~↵


But, when I instead use a function to evaluate the same expressions, the solution fails at test case 16.↵

~~~~~↵
double av1 = ValAt(i, k);↵
double av2 = ValAt(i, k-1);↵
~~~~~↵

The function:↵

~~~~~↵
double ValAt(int i, int k)↵
{↵
    ll sum = a[i] + com[n]-com[n-k] + com[i-1]-com[i-1-k];↵
    return sum/(double)(2*k+1);↵
}↵
~~~~~↵

Does any one have a rational explanation to this?↵
Here are the two submissions:↵
[submission:28570229] , [submission:28570252]↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Afifii 2017-07-15 13:57:34 15
en1 English Afifii 2017-07-15 13:48:22 831 Initial revision (published)