## 11173 - Grey Codes

Moderator: Board moderators

Oyhama Hora
New poster
Posts: 3
Joined: Tue May 24, 2005 10:58 pm

### 11173 - Grey Codes

Hi,
Who know make this problem.
i dont know the logic or the sequence for this problem.
Oyhama

Piklu_sust
New poster
Posts: 23
Joined: Fri Sep 01, 2006 10:17 am
Location: CSE, SUST

### Re: 11173 - Grey Codes

You can solve this problem using some bitwise operation.
For more details:
Art of Computer programming by Donald Knuth (Volume-4)

Tanmoy1228
New poster
Posts: 10
Joined: Sat Jul 19, 2014 2:55 am

### Re: 11173 - Grey Codes

again and again WA.
but can not got the cause.

Code: Select all

``````Remove After AC
``````
Last edited by Tanmoy1228 on Wed Feb 11, 2015 6:40 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 11173 - Grey Codes

As i understand you form binary number in bin but in decimal base.
For n = 30 and some values of k value of bin can be about 10^30.
Max value of unsigned long long is 18446744073709551615.

Change bin to string variant.
Or do it using bitwise operations - &, | <<, >>. It will become very easy when you learn it.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 11173 - Grey Codes

Here some input for which your program gives wrong output

Code: Select all

``````8
15 2246
11 1516
11 1427
14 13986
14 8558
14 10876
14 6252
12 2537``````
Ac output

Code: Select all

``````3237
1818
1882
11763
12761
16194
5210
3357
``````
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Tanmoy1228
New poster
Posts: 10
Joined: Sat Jul 19, 2014 2:55 am

### Re: 11173 - Grey Codes

lighted wrote:As i understand you form binary number in bin but in decimal base.
For n = 30 and some values of k value of bin can be about 10^30.
Max value of unsigned long long is 18446744073709551615.

Change bin to string variant.
Or do it using bitwise operations - &, | <<, >>. It will become very easy when you learn it.
Thank you lighted....