Submit | All submissions | Best solutions | Back to list |
CHANPON - Chacha And Pongo |
Chacha and Pongo are great friends. Chacha loves to solve puzzles and Pongo always keeps one ready for him. Pongo takes pen and paper starts describing the problem to him. Given a number N as the root of a tree. Every node with value P has all the factors except the trivial factors of P as child nodes. Now given a number X, Chacha needs to find the number of occurrence of X in the tree. This time Chacha is having tough time solving the puzzle. Can you help him.
Note: Trivial factors of a number are 1 and itself.
Input
Input contains 2 lines. The first line of the input will contain N - the value at the root node. (1 <= N <= 10^12). The second line of the input will contain X (1 <= X <= N)
Output
Number of occurrences of X in the tree with root node N.
Example
Input: 8 2 Output: 2
Tree formed for 8 will look like:
8 / \ 2 4 \ 2
Added by: | Aditya Dixit |
Date: | 2015-02-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
2015-04-16 05:33:07 cs
weak test case. can you review your test case pls? |
|
2015-02-21 16:01:19 Kishlay Raj
thanku |