Hi i tried out a code in c and considering that all variables in the following line of code were of "long long int",
money=(money % 1000000007)+(((2*pow(abs(a[i]-a[j]),k))%1000000007) % 1000000007);
i received an error which states that
error: invalid operands to binary % (have 'double' and 'int')
money=(money % 1000000007)+(((2*pow(abs(a[i]-a[j]),k))%1000000007))) % 1000000007);
^
I did not understand what the error meant in this case because i did not use double.Could i get a brief explanation ?
% is an integer operator and pow() returns a double. So, you may need to use fmod or fmodf or convert everything to int.
money=(money % 1000000007)+(((2*(long long int)pow(abs(a[i]-a[j]),k))%1000000007))) % 1000000007);