Hi,
Who know make this problem.
i dont know the logic or the sequence for this problem.
Oyhama
11173 - Grey Codes
Moderator: Board moderators
-
- 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:
Read the following book:
Art of Computer programming by Donald Knuth (Volume-4)
For more details:
Read the following book:
Art of Computer programming by Donald Knuth (Volume-4)
-
- New poster
- Posts: 10
- Joined: Sat Jul 19, 2014 2:55 am
Re: 11173 - Grey Codes
Last edited by Tanmoy1228 on Wed Feb 11, 2015 6:40 pm, edited 1 time in total.
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.
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
Re: 11173 - Grey Codes
Here some input for which your program gives wrong output
Ac output
Code: Select all
8
15 2246
11 1516
11 1427
14 13986
14 8558
14 10876
14 6252
12 2537
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
-
- New poster
- Posts: 10
- Joined: Sat Jul 19, 2014 2:55 am
Re: 11173 - Grey Codes
Thank you lighted....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.