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 »

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 »

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 »

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: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11173 - Grey Codes

Post by lighted »

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: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11173 - Grey Codes

Post by lighted »

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 »

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)”