You are not logged in. Please login at www.codechef.com to post your questions!

×

Natural number k satisfying k & x = k

How do I find all natural numbers k satisfying k & x == k for some Natural Number x?

asked 16 Jan, 17:03

rds_98's gravatar image

2★rds_98
456
accept rate: 9%

SOS dp. Read the codeforces article.

(16 Jan, 18:15) vijju123 ♦♦5★

You can just go through the sub-optimal solution mentioned here:

http://codeforces.com/blog/entry/45223

link

answered 16 Jan, 18:20

abdullah768's gravatar image

6★abdullah768
2.4k420
accept rate: 17%

you can convert the number x into binary form i.e 15=1+2+4+8 and 13=1+4+8 and make array of all these numbers i.e array for 15={1,2,4,8} and array for 13 will be {1,4,8} and the find the subsets of this array... and just add elements of each of them.. so 15 will update all elements from 1 to 15 as all numbers can be computed using elements of that array.. EDIT: well, there may be another optimised soln about which i am not aware

link

answered 16 Jan, 23:47

l_returns's gravatar image

4★l_returns
1.3k19
accept rate: 26%

edited 16 Jan, 23:49

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×226
×182
×94
×37
×3

question asked: 16 Jan, 17:03

question was seen: 432 times

last updated: 16 Jan, 23:49