The subject requirements are as follows:
Additive variable multiplication
We all know: 1+2+3+. + 49 = 1225
Now you're asked to turn the two nonadjacent plus signs into multiplication, making the result 2015.
Like what:
1+2+3+...+10*11+12+...+27*28+29+...+49 = 2015
Is the answer that meets the requirements.
Please look for another possible answer,
and put the position of the front of the multiplication to the left of the number submitted (for example, is submitted 10).
Note: You are required to submit an integer, do not fill in any superfluous content.
Ideas:
1. Said the idea is actually no idea, according to the normal solution step-by-step procedures to write the OK.
2. Will 1+2+3+ + 49 of which two "+" into "*", with a double loop to traverse all possible results.
3. The outer loop of the variable I represents the previous "*", the inner loop of J represents the latter "*", followed by traversal.
4. Use variable TMP to save the result of changing the previous "+" in the program to "*". The code is TMP = RES = sum-(i+ (i-1)) +i* (i-1), which the reader needs to understand carefully.
5. Use the variable res to save the result of changing the latter "+" in the program to "*". The code is res = tmp-(j+ (j-1)) +j* (j-1).
6. Then the variable res determines whether the value is 2015. If yes, output I and the value for J. (the title only asks for the position of the previous "*", that is, the value of i).
The source code is as follows: