Algorithm of 11933 - Splitting Numbers

Problem Description Link
Algorithm:

This is a simple problem the operation of splitting a binary number n into two numbers a(n), b(n) .
you need to convert decimal to binary format for a given number and from that binary format create two numbers
a(n) and b(n). To build first value a(n) need to choice 1st  1  ,3rd  1, 5th  1,..... so on same position of original binary format other position fii by the value 0.
To build second value b(n) need to choice 2nd  1  ,4th  1, 6th  1,..... so on same position of original binary format other position fill by the value 0.

for example

n=13
1
1
0
1
binary format
                                              
          3                 2                      1              0                 index

1(3rd 1)
0
0
1 (1st 1)
For a(n) 

0
1(2nd 1)
0
0
For b(n)
      

So a= 9 and b=4 
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience