Does anyone have a simpler approach of solving this problem? Please share with me.

# | User | Rating |
---|---|---|

1 | tourist | 3557 |

2 | Radewoosh | 3468 |

3 | Um_nik | 3429 |

4 | Petr | 3354 |

5 | Benq | 3286 |

6 | mnbvmar | 3280 |

7 | wxhtxdy | 3276 |

7 | LHiC | 3276 |

9 | ecnerwala | 3214 |

10 | yutaka1999 | 3190 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 191 |

2 | Radewoosh | 180 |

3 | tourist | 173 |

4 | Vovuh | 165 |

4 | PikMike | 165 |

4 | antontrygubO_o | 165 |

7 | rng_58 | 160 |

8 | majk | 156 |

8 | Um_nik | 156 |

10 | 300iq | 155 |

Does anyone have a simpler approach of solving this problem? Please share with me.

↑

↓

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/18/2019 20:42:19 (e1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

if u can understand python the refer to my solution https://codeforces.com/contest/1152/submission/53235674 starting from MSB following a greedy type appraoch

Can you explain your logic I have difficulty in reading python. Thanks!

first of all i converted the number into its binary and then checked if all bits are set if not then i start traversing from the most significant bit if a bit is set then continue else i calculated the length of all the bits starting from that '0' bit and then xored it with the number(all bits set with the lenght i calculated) AND then checked if the number becomes 2^n-1 (break if yes) else continue till the number becomes 2^n-1 (till we reach the last bit). take an example and u will understand refering to my code

Thanks! Understood

your approach is intuitive, Thanks

can you find the mistake in my code? I am new to coding. Here is my solution,I got testcase 4 wrong!! solution

sorry for the down vote by mistake:)

No problem. I don't care about those a question is a question l.

I finally solved it using almost the same idea of yours. AC in 7 goes. my solution Thanks!.

Thanks for asking the doubt , my doubt is also cleared.