Uva 10254.the priest mathematician

Nov 18, 2009

Problem: 10254.the priest mathematician

Description:

1. If number of disk is 0, then move 0.
2. If number of disk is 1, then move 1.
3. If number of disk is 2, then move 3.
4. If number of disk is 3, then move 5.
5. If number of disk is 4, then move 9.
6. If number of disk is 5, then move 13.
7. If number of disk is 6, then move 17.
8. If number of disk is 7, then move 25.
9. If number of disk is 8, then move 33.

10. If number of disk is 9, then move 41.
11. If number of disk is 10, then move 49.
12. If number of disk is 11 then move 65.
13. If number of disk is 12, then move 81.
14. If number of disk is 13, then move 97.
15. If number of disk is 14, then move 113.
16. If number of disk is 15, then move 129.
So from disk number 2, we find a series,
3,5,9,13,17,25,33,41,49,65,81,97,113,129……………………………
Algorithm:


Code In ANSI C:



Code In C++:

Code In Java:

No comments:

Post a Comment