11173 - Grey Codes

All about problems in Volume 111. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

11173 - Grey Codes

Post by Oyhama Hora » Sun Apr 15, 2007 10:32 pm

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

Post by Piklu_sust » Thu Jun 12, 2008 3:00 pm

You can solve this problem using some bitwise operation.
For more details:
Read the following book:
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

Post by Tanmoy1228 » Sat Jul 19, 2014 3:14 am

please help.
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

Post by lighted » Tue Jul 22, 2014 11:50 am

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

Post by lighted » Tue Jul 22, 2014 6:39 pm

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

Post by Tanmoy1228 » Wed Feb 11, 2015 6:39 pm

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....

Post Reply

Return to “Volume 111 (11100-11199)”