Use php to solve a mathematical problem [There are already many experts to solve and look forward to the emergence of better algorithms]-PHP source code

Source: Internet
Author: User
Ec(2100000000www.111cn.nethtml0054500_itemid_29653.html is a six-digit number. When we multiply it by 2, 3, 4, 5, and 6 respectively, the five products we get are a six-digit number, in addition, the five numbers are composed of the original six numbers, but the order has changed! Please help me solve this problem! --------------- It seems that everyone has a default phenomenon: www.111cn. netview script ec (2); script

Http://www.111cn.net/html/00/54500_itemid_29653.html

A six-digit number. When we multiply it by 2, 3, 4, 5, and 6, the five products are a six-digit number, and the five numbers are composed of the first six digits, the order is changed!
Please help me solve this problem!




---------------

It seems that everyone has a default phenomenon.
Http://www.111cn.net/viewthread.php? Tid = 54377 & page = 5 # pid394850

The previous assumption seems that we do not consider this situation when making algorithms. If any one has demonstrated that this assumption is not true, or the author's question itself does not consider this assumption by default. let's explain

If there is no argument or the question is not clear, it means that if you do not consider this hypothetical algorithm design, it is not suitable for the ineffective algorithm.


------------------------



Two algorithms are written:
The first idea is to judge whether the sum of the bits of the multiplied number is equal, but the efficiency is not very good.
The second algorithm is used for reverse character verification, because the forward will have a part of high-level unnecessary operations. The code is concise and efficient. The code is attached:

The first algorithm is used to determine the sum of individual digits:


========================================================== ==============================

The second algorithm is used for reverse character query:



The first algorithm needed 440 ms on my PE2140@2.66GHz, and the second took 180 ms.




---------------------------------



I mentioned this before, http://www.111cn.net/bbs/thread-54377-2-1.html.

The solution is as follows:
Obtain each bit and exclude it one by one.
If the two digits are the same, the two digits are deleted or modified at the same time.
For example:
''000000'' and ''000000''
If you delete or change the value one by one, the remaining one will not be supported.





----------------------------------



For ($ I = 100000; $ I <166667; $ I ++) // number range
{
....
For ($ ii = 2; $ ii <7; $ ii ++) // a multiple of 2-6
{
.....
For ($ j = 0; $ j <6; $ j ++) // Number of numbers
{
If (strpos ($ I, substr ($ I * $ ii, $ j,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.