TLE 90分求助
查看原帖
TLE 90分求助
1052869
AkiraN楼主2023/7/31 11:58

如题

#include <stdio.h>
#include <math.h>
int main()
{
    unsigned int n,p;
    scanf("%d",&n);
    p=sqrt(n);
    p+=((p*p)!=n);
    if ((p==2)&&(n%p==0))
    {
        printf("%d",n/p>p?n/p:p);
        return 0;
    }
    p+=(p+1)%2;
    for (;p<n;p+=2)
    {
        if (n%p==0)
        {
            printf("%d",p);
            return 0;
        }
    }
    //err
    printf("-1");
    return 0;
}
2023/7/31 11:58
加载中...