CDRSANJ - CODER FIRST PROBLEM


 

<strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p>
<strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p>
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p><strong>CODER SANJAY</strong> is now ready to put up his first problem in his favorrite website <strong>SPOJ</strong>.As it is his first problem,he wanted it to be easy so that most of them could get an <strong>AC</strong>.
The problem statement looks like this:
<p>
<br><strong>F(x)</strong> is a function whose properties are as follows.</br>
<p>1.<strong>F(x)=0</strong> at x=0.</p>
<p>2.<strong>F(x)=1</strong> at x=1.</p>
<p>3.<strong>F(x)=2</strong> at x=2.</p>
<p>4.<strong>F(x)=0</strong> if x is odd prime.</p>
<p>5.<strong>F(ab)=F(a)+F(b)</strong>,where a,b are two positive integers and sum of a and b is minimum.</br>
</p>
<br>Your task is simple.You are to output the value of <strong>F(x)</strong> for the given input integer <strong>x</strong>. </br>
Input
The only line of input contains a single integer <strong>x</strong>. 
Output
Output the value of <strong>F(x)</strong>
Example
Input:
<p>
4
</p>
Output:
<p>
4
</p>

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.

 

CONSTRAINSTS:

0 < x < 100001.

Input

The only line of input contains a single integer x

Output

Output the value of F(x).


Example

Input:

4

Output:

4


hide comments
get_right_jr: 2016-06-20 11:54:08

Awesome problem
AC in first attempt

Vaporeon: 2016-05-11 22:03:26

easy rec :)

pavithranrick: 2016-05-10 16:25:42

This is a basic problem...so who haven't solved more than 30 problems can give this a try!!!

PS: This is comment is just for motivating those guys...

Last edit: 2016-05-10 16:27:11
rayhan50001: 2016-04-26 16:34:41

nice one.. AC in 2nd.

Murad Al Wajed: 2016-04-24 08:29:11

nice problem. ac in 1

Shashank Tiwari: 2016-04-16 02:34:59

This is a beautiful problem especially if you try to prove why our method gives minimun answer. You dont have to dig into sieve and store prime numbers . Concentrate on Pattern and above all try to prove things by induction. Your solution should work even if x is 10^19 (Ideally speaking!!).

Last edit: 2016-04-22 16:34:13
utkarsh538: 2016-04-13 22:14:36

easy one,just find the logic. No use of finding prime numbers.

ghost_wire: 2016-03-21 10:17:59

Easy one my 30th problem.

aman anand: 2016-03-16 02:35:37

ac in 1st attempt

Last edit: 2016-03-16 05:22:15
Kyle Dencker: 2016-03-15 03:06:45

Fun good problem.

Last edit: 2016-03-15 04:03:51

Added by:verdu sanjay
Date:2016-03-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: GOSU