This question refers to breaking down big numbers. The number range is Longlong, and it seems that it cannot be violent. However, the question provides a condition, with at most one reason
The child size exceeds 1000000. Haha, This is a storm. In this case, we can enumerate the factors of less than 1000000. If the remaining part is greater than 6 times of 10
It must be a factor of N, so no violence is needed. If the number is less than 10, it must be 1 for 6 times, because the 2-000000 factors are all processed.
In this way, the question will not time out. Indeed, violence requires skill. Also note that % lld is used for the request.
# Include <stdio. h>
# Include <math. h>
Typedef long LL;
# Define MAX (6000000)
Bool bPrime [MAX];
Int nPrime [MAX];
Int nNum;
Void InitPrime ()
{
LL nMax = sqrt (MAX) + 1;
BPrime [0] = bPrime [1] = true;
For (int I = 2; I <= nMax; ++ I)
{
If (! BPrime [I])
{
For (int j = 2 * I; j <MAX; j + = I)
{
BPrime [j] = true;
}
}
}
For (int I = 2; I <MAX; ++ I)
{
If (! BPrime [I])
NPrime [nNum ++] = I;
}
}
Bool IsPrime (LL nN)
{
If (nN <MAX) return! BPrime [nN];
LL nMax = sqrt (double) nN) + 1;
For (LL j = 0, I = nPrime [j]; I <= nMax; ++ j, I = nPrime [j])
{
If (nN % I = 0)
{
Return false;
}
}
Return true;
}
Int main ()
{
LL nN;
InitPrime ();
While (scanf ("% lld", & nN), nN> = 0)
{
If (nN <= 2)
{
Printf ("%-lld \ n", nN );
Continue;
}
Int nMax = sqrt (double) nN) + 1;
For (LL I = 2; I <= 1000000 & I <= nMax; ++ I)
{
While (nN % I = 0)
{
Printf ("%-lld \ n", I );
NN/= I;
}
If (nN <6000000 & IsPrime (nN ))
{
Break;
}
}
If (nN! = 1)
Printf ("%-lld \ n", nN );
Printf ("\ n ");
}
Return 0;
}