Hi codeforcer.
So let's cut right to the chase given N where 1<=N<=5000000 find the number of the prime factors the make up N.
e.g. 6=2*3 =>the answer for 6 is 2.
e.g. 12=2*2*3 =>the answer for 12 is 3.
I think it's called prime factorialzition or prime decomposition I'm not sure since my English with math vocabulary is worse than my coding skills.
Please keep it simple.
Thanks in advance.
for ( int i=2 ; i<=n ; i++ ) { { while ( n%i==0 ) { n/=i; c++; } } }
the answer is c
Yes that's right but you see I have to make this operation 1000000 times for different integers so your solution will take long but thank you anyway.
You can make the worst case performance (n is actually prime) faster simply by testing up to sqrt(n)+1 instead of just n.
But yeah, if you're going to be making tons of queries, then tweety's preprocessed sieve would be the way to go!
I think the code is self-explanatory
UPD: the above comment has complexity O(n). My code has O(nlogn) preprocessing and O(logn) per query. (n should be less than MAXN)
by query I mean number to check
Thank you.