《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

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

Hot Article
How to fix KB5055523 fails to install in Windows 11?
4 weeks ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
4 weeks ago
By DDD
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks ago
By DDD
Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How to fix KB5055612 fails to install in Windows 10?
3 weeks ago
By DDD

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
Java Tutorial
1663
14


CakePHP Tutorial
1420
52


Laravel Tutorial
1313
25


PHP Tutorial
1266
29


C# Tutorial
1239
24

