当前位置:网站首页>Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
2022-07-05 08:21:00 【Lazy smile】
example 003: Complete square
subject : An integer , It adds 100 And then there's a complete square , Plus 168 It's a complete square again , What is the number ?
Program analysis : because 168 It's too small for an exponential explosion , Therefore, mathematical analysis can be omitted directly , Use the simplest way to get the upper limit ,
n = 0
while (n + 1) ** 2 - n * n <= 168:
n += 1
print('----n=', n) # It can be concluded that the range is (n+1)**2 Inside The train of thought is :
The worst result is n The sum of the squares of (n+1) The square of is just the difference 168, Because it's Square , There can be no greater gap than this .
Let this number be i (i+100)**0.5 (i+100+168)**0.5 Then the results are all integers .
As for judging whether it is a complete square number , The easiest way is : The value of the square root is decimal 0 that will do .
for i in range((n + 1) ** 2):
if i ** 0.5 == int(i ** 0.5) and (i + 168) ** 0.5 == int((i + 168) ** 0.5):
print(i - 100)The combination is :
# The worst result is n The sum of the squares of (n+1) The square of is just the difference 168, There can be no greater gap than this , Based on this, we come to the conclusion that n
n = 0
while (n + 1) ** 2 - n * n <= 168:
n += 1
print('----n=', n) # It can be concluded that the range is (n+1)**2 Inside
for i in range((n + 1) ** 2):
if i ** 0.5 == int(i ** 0.5) and (i + 168) ** 0.5 == int((i + 168) ** 0.5):
print(i - 100)------n= 84
-99
21
261
1581Therefore, the number can be :-99 21 61 1581

边栏推荐
- 亿学学堂给的证券账户安不安全?哪里可以开户
- Halcon's practice based on shape template matching [2]
- Hardware 1 -- relationship between gain and magnification
- leetcode - 445. 两数相加 II
- Soem EtherCAT source code analysis II (list of known configuration information)
- 關於線性穩壓器的五個設計細節
- Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
- Explain task scheduling based on Cortex-M3 in detail (Part 1)
- Explication de la procédure stockée pour SQL Server
- Briefly talk about the identification protocol of mobile port -bc1.2
猜你喜欢

STM32 single chip microcomputer - bit band operation

Array integration initialization (C language)

Take you to understand the working principle of lithium battery protection board

【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
![Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine](/img/a1/d13b37955b044b6be5f1fd10263c5e.jpg)
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
![[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication](/img/05/0f63e4cd3da24e5b956ec5899b939d.jpg)
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication

MySQL之MHA高可用集群

Briefly talk about the identification protocol of mobile port -bc1.2

Several important parameters of LDO circuit design and type selection

Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
随机推荐
关于线性稳压器的五个设计细节
C language # and #
Various types of questions judged by prime numbers within 100 (C language)
Solutions to compilation warnings in Quartus II
Hardware and software solution of FPGA key chattering elimination
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
STM32---ADC
Naming rules for FreeRTOS
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
2020-05-21
Count the number of inputs (C language)
C WinForm [display real-time time in the status bar] - practical exercise 1
STM32 --- configuration of external interrupt
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
C WinForm [change the position of the form after running] - Practical Exercise 4
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
Soem EtherCAT source code analysis II (list of known configuration information)
The firmware of the connected j-link does not support the following memory access
剑指 Offer 05. 替换空格
Detailed explanation of SQL server stored procedures