《Ruby太慢了》php版回文数计算代码
<?php //给出两个数值X和Y,统计在这个区间里的回文数,并且要求它们的平方根也是回文数。其中 1<= x <= y < 10 14 error_reporting(E_ALL); ini_set("display_errors", 1); //避免超时 set_time_limit(0); $t1=microtime(); function isPlalindrome($num){ $str="$num"; $len=strlen($num); $k = intval($len/2) + 1;//获取中间位数 for($j=0;$j<$k;$j++){ if($str{$j}!=$str{$len-1-$j}){ return false; } } return true; } function showPlalindrome($min,$max){ //因为要计算在$min,$max间的回文数且其自身平方根也是回文数,所以相当于求一sqrt($min)~sqrt($max)间数,其平方在$min~$max间也是回文数 //$min~$max是连续正整数,所以可以这样缩小很多计算量,否则…… $start=sqrt($min); $end=sqrt($max); for($i=$start;$i
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
2 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

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
CakePHP Tutorial
1376
52

