search
Homephp教程php手册把1316这个数表示成两个数的和,其中一个为13的倍数,另一个是11的倍数,求这两个数。

算法分析:

1316,显然1300是13的倍数,但16不是11的倍数,可以想到从1300上任意减去N个13的倍数其结果仍然是13的倍数,那么只要16加上这个减去的N个13的倍数其和是11的倍数,这两个数就解出来了,答案可能不只一个,但是我们只求一对解就可以了。

仔细观察不难发现:(16+13*3)+(1300-13*3)=1316,但是我们需要用代码实现:

复制代码 代码如下:


$n=1316;
$i=0;//减去的第N个13,进行初始化为0
$y=16+13*$i;//1316分出来的16加上N个13,这里初始化为16
while($y%11!=0){//如果16加上N个13的和不能整除11
$i++;//再加一个13
$y=16+13*$i;
}

echo '$x='.($n-$y).'
';
echo '$y='.$y;
?>

Statement
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools