<svg style="display: none;" xmlns="http://www.w3.org/2000/svg"> </svg>
下面介绍一种求 <math> <semantics> <mrow> <mi> n </mi> </mrow> <annotation encoding="application/x-tex"> n </annotation> </semantics> </math>n的所有因数的方法。
void ben(int n)
{
for(int i=1;i<=sqrt(n);i++)
{
if(n%i==0)
{
a[++cnt]=i;
if(n!=i*i)
a[++cnt]=n/i;
}
}
}