CDRSANJ - CODER FIRST PROBLEM
CODER SANJAY is now ready to put up his first problem in his favorite website SPOJ.As it is his first problem,he wanted it to be easy so that most of them could get an AC.
The problem statement looks like this:
F(x) is a function whose properties are as follows.
1.F(x)=0 at x=0.
2.F(x)=1 at x=1.
3.F(x)=2 at x=2.
4.F(x)=0 if x is odd prime.
5.F(a*b)=F(a)+F(b),where a,b are two positive integers and sum of a and b is minimum.
Your task is simple.You are to output the value of F(x) for the given input integer x.
0 < x < 100001.
The only line of input contains a single integer x.
Output the value of F(x).
don't forget that in f(a*b)=f(a)+f(b) ,f(a) and f(b)can further be individually expressed as f(x)+f(y) where x*y=a
observe the pattern and you'll get it!!!
don't be discouraged ,if you are not able to solve it ,try,try,and keep on trying .
f(2) important hai..
Pretty interesting problem. But the tags are misleading -- just ignore them.
I suggest not to see comments while solving this problem. It's a quite simple problem.But takes time for the idea to strike.
Quite easy. Nice usage of recursion.
no need to use dp
game of odd and even..!!!!
Numerous ways to solve this problem. 2 Naive Approaches, DP, Recursion.