Algorithm: reverse all the positives; if(product is negative) reverse the smallest one.
Proof:
With step1, we got the ABS of the product the greatest.
After step 1, we got the product:
1)positive: No step2. We are done.
2)negative: suppose the product after step 1 is (-1000)*(-2)*k(k<0) .Either we choose (-1000)*1*k, or 999*(-2)*k;
In general, a*(a+b)*k(b,k<0). 1st choice:(-a-1)*(a+b)*k; 2st choice a*(-a-b-1)*k. To make a comparision:((-a^2-a-ab-b)-(-a^2-ab-a))*k=-b*k<0, so we choose to reverse the smallest one.
Auto comment: topic has been updated by qingyuge006 (previous revision, new revision, compare).
B not C
What's clever in that?
Maybe you are too smart