Title: An integer plus 100 after it is a perfect square, plus 168 is a perfect square, what is the number is how much?
Program analysis: can be filled in one hundred, ten digital bits are 1,2,3,4. Composition before removing all permutations arrangement conditions are not satisfied.
Assuming that the number x.
1, then: X = 100 + n- 2 , X m + 100 + 168 = 2
2, calculation equation: m 2 - n- 2 = (n-m +) (m - n-) = 168
3, is provided: m + n = i, m - n = j, i * j = 168, i and j is an even number at least one
4, can be obtained: m = (i + j) / 2, n = (i - j) / 2, i and j are either both even or both odd.
5, 3, and 4 derived from know, I and j are both an even number greater than or equal to 2.
6, since i * j = 168, j> = 2, the . 1 <I <168/2 +. 1 .
7, all numbers next cycle i can be calculated.
Source Codes (formerly Python2.0):
This calculation method is very interesting, to be studied
My source code:
# ! / Usr / bin / Python # encoding = UTF-8 # - * - Coding: UTF-8 - * - # Title: An integer that after 100 plus is a perfect square, plus 168 is a perfect square, what is the number is how much? # Problem-solving ideas: first find the approximate range of the number of Z # by definition function to determine whether each of the number of perfect square, meets conditions of the subject; # verify whether perfect square Import Math DEF isSqr (n-): A = int ((Math.sqrt (n-))) return a == * a n- # return value of the function is defined, for a perfect square, returns True, the non-perfect square returns False; # answer to the judgment by this cycle boundary , for the next cycle of the input parameters; # with the increase of a factor of t, which is the square of the difference between the square of t + 1 will be more and more, so this rule set by the cycle # difference between the sum of two squares full title of 168 for the y- inrange (0,10000 ): IF (. 1 + Y) ** 2-Y ** 2> = 168 : Z = Y 2 +. 1 ** # time range iteration, not the second parameter Print ( " Y: " , Y, " Z: " , Z) BREAK # minimum value should start -100 for I in Range (-100 , Z): IF I 10% in [0,1,4,5,6,9]: # The Features fully square numbers, these are only single-digit number. IF isSqr (I + 100) and isSqr (I + 268 ): Print (I, " ## " , (I + 100) ** 0.5,"&&&",(i+268)**0.5)
Output:
C:\Python30_demo>python 018demo.py y: 84 z: 7057 -99 ## 1.0 &&& 13.0 21 ## 11.0 &&& 17.0 261 ## 19.0 &&& 23.0 1581 ## 41.0 &&& 43.0
A total of four numbers, -99,1,21,261,1581
-------- (I am dividing line) --------
reference:
1. RUNOOB.COM : https://www.runoob.com/python/python-exercise-example3.html
2. https://www.cnblogs.com/zlsjjn/p/7459607.html
3. Baidu Encyclopedia: https://baike.baidu.com/item/%E5%AE%8C%E5%85%A8%E5%B9%B3%E6%96%B9%E6%95%B0/8025061? fr = aladdin
Remarks:
Initial modified: September 22, 2019 23:37:37
First Review: September 23, 2019 00:06:08 / modify the format and some duplicate content
Environment: Windows 7 / Python 3.7.2