Blue Bridge Cup sixth provincial race topic-addition variable multiplication (Java)
Topic:
we all know: 1+2+3+ ... + $ = 1225
you are now asked to turn two of these nonadjacent plus signs into multiplication sign, making the result -
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 submit the number to the left of the front multiplication sign (for example, commit Ten ).
Note: You are required to submit an integer, do not fill in any superfluous content.
My train of thought : Example: 1+2+3+...+10*11+12+...+27*28+29+...+49 =
We split 10*11 = 10+10*10 27*28 = 27+27*27
Translate to: 1+2+3+...+9+10+10*10+ 12+...+26+27+ 27*27+29+...+49 =
Both sides plus 11+28
1+2+3+...+9+10+10*10+11+ 12+...+26+27+ 27*27+28+29+...+49 = 2015+11+28
convert to: 1225+ 10*10+27*27 = 2015+11+28= 2017+10+27
According to this idea: using two-layer cyclic i,j to represent the position of multiplication sign respectively to obtain the judging conditions
1225+ i*i + j*j = = 2017+i+j
Public class Demo6 { publicstaticvoid main (string[] args) { for ( int i = 1; I < 49; i++) { for (int j = i + 2; j <; J + +) {if (1225 + i * i + J * j = + i + j) { System.out.println (i); }}}}
Execution Result: 10 16
Answer: 16
Blue Bridge Cup-addition variable multiplication (Java)