用php解決一個(gè)數(shù)學(xué)題【已有很多高手解決,期待更好的算法的出現(xiàn)】
Jun 08, 2016 pm 05:32 PM一個(gè)六位數(shù),當(dāng)分別用2,3,4,5,6乘它后,得到的五個(gè)乘積都是一個(gè)六位數(shù),而且這得到的五個(gè)數(shù)是由原來(lái)六個(gè)數(shù)字組成,只是順序改變了!
求高手幫助解決下!
---------------
貌似大家都默認(rèn)了一個(gè)現(xiàn)象
http://www.111cn.net/viewthread.php?tid=54377&page=5#pid394850
之前提出的一個(gè)假設(shè) 貌似大家做算法的時(shí)候都不考慮這種情況的存在可能 如果哪位有論證過(guò)這種假設(shè)不成立或者樓主的題目本身就默認(rèn)不考慮這種假設(shè) 請(qǐng)大俠們說(shuō)明一下
如果沒(méi)有論證或者題目沒(méi)有明確說(shuō)明不考慮這種假設(shè) 算法設(shè)計(jì)再好也是不合題意的無(wú)效算法
------------------------
寫(xiě)了兩種算法:
第一種思路是判斷相乘的數(shù)的各個(gè)位之和是否相等,不過(guò)效率不太好。
第二種算法換了一種思路,用了字符反方向驗(yàn)證,因?yàn)檎驎?huì)有一部分高位的不必要的運(yùn)算。代碼很簡(jiǎn)潔,效率很不錯(cuò),附上代碼:
第一種算法,判斷各個(gè)位數(shù)之和:
===========================================================
第二種算法,字符反方向查詢:
第一個(gè)算法在我的PE2140@2.66GHz上需要440ms,第二種只需要180ms。
---------------------------------
我之前提過(guò)這個(gè)問(wèn)題了http://www.111cn.net/bbs/thread-54377-2-1.html
解決的方法有一個(gè):
得出每一位,逐個(gè)位排除.
如得兩個(gè)位數(shù)相同,則兩個(gè)同時(shí)刪除或更改.
比如:
''123451''和''123456''
逐位刪除或更改的話,剩下的一位就不等了.
----------------------------------
for($i = 100000;$i {
....
? ?? ???for($ii=2;$ii ? ?? ???{
.....
? ?? ?? ?? ?? ? for($j=0;$j ? ?? ?? ?? ?? ? {
if(strpos($i,substr($i*$ii,$j,

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You can embed PHP code into HTML files, but make sure that the file has an extension of .php so that the server can parse it correctly. Use standard tags to wrap PHP code, insert dynamic content anywhere in HTML. In addition, you can switch PHP and HTML multiple times in the same file to realize dynamic functions such as conditional rendering. Be sure to pay attention to the server configuration and syntax correctness to avoid problems caused by short labels, quotation mark errors or omitted end labels.

To reduce the size of HTML files, you need to clean up redundant code, compress content, and optimize structure. 1. Delete unused tags, comments and extra blanks to reduce volume; 2. Move inline CSS and JavaScript to external files and merge multiple scripts or style blocks; 3. Simplify label syntax without affecting parsing, such as omitting optional closed tags or using short attributes; 4. After cleaning, enable server-side compression technologies such as Gzip or Brotli to further reduce the transmission volume. These steps can significantly improve page loading performance without sacrificing functionality.

HTMLhasevolvedsignificantlysinceitscreationtomeetthegrowingdemandsofwebdevelopersandusers.Initiallyasimplemarkuplanguageforsharingdocuments,ithasundergonemajorupdates,includingHTML2.0,whichintroducedforms;HTML3.x,whichaddedvisualenhancementsandlayout

It is a semantic tag used in HTML5 to define the bottom of the page or content block, usually including copyright information, contact information or navigation links; it can be placed at the bottom of the page or nested in, etc. tags as the end of the block; when using it, you should pay attention to avoid repeated abuse and irrelevant content.

Adeclarationisaformalstatementthatsomethingistrue,official,orrequired,usedtoclearlydefineorannounceanintent,fact,orrule.Itplaysakeyroleinprogrammingbydefiningvariablesandfunctions,inlegalcontextsbyreportingfactsunderoath,andindailylifebymakingintenti

ThetabindexattributecontrolshowelementsreceivefocusviatheTabkey,withthreemainvalues:tabindex="0"addsanelementtothenaturaltaborder,tabindex="-1"allowsprogrammaticfocusonly,andtabindex="n"(positivenumber)setsacustomtabbing

inputtype="range" is used to create a slider control, allowing the user to select a value from a predefined range. 1. It is mainly suitable for scenes where values ??need to be selected intuitively, such as adjusting volume, brightness or scoring systems; 2. The basic structure includes min, max and step attributes, which set the minimum value, maximum value and step size respectively; 3. This value can be obtained and used in real time through JavaScript to improve the interactive experience; 4. It is recommended to display the current value and pay attention to accessibility and browser compatibility issues when using it.

The standard way to add titles to images in HTML is to use and elements. 1. The basic usage is to wrap the image in the tag and add a title inside it, for example: this is the title of the image; 2. The reasons for using these two tags include clear semantics, convenient style control, and strong accessibility, which helps the browser, crawler and screen readers to understand the content structure; 3. Notes include that it can be placed up and down but needs to maintain logical order, cannot replace the alt attribute, and can contain multiple media elements to form a whole unit.
