Click here to Skip to main content
16,007,126 members
Home / Discussions / C#
   

C#

 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn30-Apr-07 4:23
sitebuilderLuc Pattyn30-Apr-07 4:23 
GeneralRe: Process.Start Parameter with space Pin
PIEBALDconsult3-May-07 15:40
mvePIEBALDconsult3-May-07 15:40 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn3-May-07 22:24
sitebuilderLuc Pattyn3-May-07 22:24 
GeneralRe: Process.Start Parameter with space Pin
PIEBALDconsult4-May-07 16:45
mvePIEBALDconsult4-May-07 16:45 
GeneralRe: Process.Start Parameter with space Pin
Luc Pattyn4-May-07 23:30
sitebuilderLuc Pattyn4-May-07 23:30 
Questionhow to display video files using asp.net Pin
manoharseetha29-Apr-07 17:06
manoharseetha29-Apr-07 17:06 
AnswerRe: how to display video files using asp.net Pin
Christian Graus29-Apr-07 17:26
protectorChristian Graus29-Apr-07 17:26 
Questioni need help in my project... Pin
hazem maher29-Apr-07 11:26
hazem maher29-Apr-07 11:26 
I want your help in my project(Hanoi Tower2)....

Towers of Hanoi

The ancient folklore behind the “Towers of Hanoi” puzzle is quite well known. A more recent legend tells us that once the Brahmin monks discovered how long it would take to finish transferring the 64 discs from the needle which they were on to one of the other needles, they decided to find a faster strategy and be done with it.

One of the priests at the temple informed his colleagues that they could achieve the transfer in single afternoon at a one disc-per-second rhythm by using an additional needle. He proposed the following strategy:

• First move the topmost discs (say the top k discs) to one of the spare needles.

• Then use the standard three needles strategy to move the remaining n − k discs (for a general case with n discs) to their destination.

• Finally, move the top k discs into their final destination using the four needles.

He calculated the value of k which minimized the number of movements and found that 18,433 transfers would suffice. Thus they could spend just 5 hours, 7 minutes, and 13 seconds with this scheme versus over 500, 000 million years without the additional needle!

Try to follow the clever priest’s strategy and calculate the number of transfers using four needles, where the priest can move only one disc at a time and must place each disc on a needle such that there is no smaller disc below it. Calculate the k that minimizes the number of transfers under this strategy.

Input

The input file contains several lines of input. Each line contains a single integer 0 ≤ N ≤ 10, 000 giving the number of disks to be transferred. Input is terminated by end of file.

Output

For each line of input produce one line of output which indicates the number of movements required to transfer the N disks to the final needle.

Sample Input

1

2

28

64

Sample Output

1

3

769

18433

can u help me....

AnswerRe: i need help in my project... Pin
Christian Graus29-Apr-07 12:30
protectorChristian Graus29-Apr-07 12:30 
GeneralRe: i need help in my project... Pin
Paul Conrad29-Apr-07 13:44
professionalPaul Conrad29-Apr-07 13:44 
GeneralRe: i need help in my project... Pin
Christian Graus29-Apr-07 14:51
protectorChristian Graus29-Apr-07 14:51 
GeneralRe: i need help in my project... Pin
Paul Conrad29-Apr-07 14:57
professionalPaul Conrad29-Apr-07 14:57 
GeneralRe: i need help in my project... Pin
Muammar©29-Apr-07 23:10
Muammar©29-Apr-07 23:10 
GeneralRe: i need help in my project... Pin
hazem maher30-Apr-07 13:59
hazem maher30-Apr-07 13:59 
AnswerRe: i need help in my project... Pin
Professor Sharada Ulhas29-Apr-07 14:19
Professor Sharada Ulhas29-Apr-07 14:19 
GeneralRe: i need help in my project... Pin
hazem maher30-Apr-07 14:02
hazem maher30-Apr-07 14:02 
AnswerRe: i need help in my project... Pin
Luc Pattyn2-May-07 8:13
sitebuilderLuc Pattyn2-May-07 8:13 
Questionlimit failed login attempts to event log Pin
Ambar Violeta29-Apr-07 5:52
Ambar Violeta29-Apr-07 5:52 
AnswerRe: limit failed login attempts to event log Pin
Arun.Immanuel29-Apr-07 6:11
Arun.Immanuel29-Apr-07 6:11 
AnswerRe: limit failed login attempts to event log Pin
Dave Kreskowiak29-Apr-07 7:23
mveDave Kreskowiak29-Apr-07 7:23 
Questionhow to change Paper Size in Crystal Report ? Pin
hdv21229-Apr-07 4:36
hdv21229-Apr-07 4:36 
QuestionDateTimePicker Problems Pin
zeroonea29-Apr-07 3:39
zeroonea29-Apr-07 3:39 
AnswerRe: DateTimePicker Problems Pin
kubben29-Apr-07 5:34
kubben29-Apr-07 5:34 
GeneralRe: DateTimePicker Problems Pin
zeroonea29-Apr-07 8:58
zeroonea29-Apr-07 8:58 
Questionproblem in distributed Application Pin
mano_meee29-Apr-07 3:21
mano_meee29-Apr-07 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.