Steve Waugh and Mark Waugh are sitting at the bottom of their tree house and debating in how many ways they can jump up the stairs on the tree and reach the tree house.
Because Steve Waugh is older than Mark Waugh, he can jump one, two, or three stairs in one step while Mark Waugh can jump just one or two stairs in one step.
Input:
The number of stairs to be covered.
Output:
Print the Number of total ways to reach to the top for Steve Waugh in the first line and Number of total ways to reach at the top for Mark Waugh in the second line.
#include <stdio.h> int i; int main() { int markwaugh,stevewaugh,n; //printf("Total number of stairs to be covered: "); scanf("%d",&n); int arr[n+1]; arr[0] = 1; arr[1] = 1; arr[2] = 2; for (i = 3; i <=n; i++) arr[i] = arr[i - 1] + arr[i - 2]+ arr[i - 3]; stevewaugh=arr[n]; for(i=2;i<=n;i++) arr[i]=arr[i - 1] + arr[i - 2]; markwaugh=arr[n]; printf("Steve Waugh:%d\nMark Waugh:%d\n",stevewaugh,markwaugh); return 0; }
INPUT_1:
Total number of stairs to be covered: 14
OUTPUT:
Steve Waugh: 3136
Mark Waugh: 610
INPUT_2:
Total number of stairs to be covered: 10
OUTPUT:
Steve Waugh: 274
Mark Waugh: 89
INPUT_3:
Total number of stairs to be covered: 20
OUTPUT:
Steve Waugh: 121415
Mark Waugh: 10946
INPUT_4:
Total number of stairs to be covered: 7
OUTPUT:
Steve Waugh: 44
Mark Waugh: 21
INPUT_5:
Total number of stairs to be covered: 3
OUTPUT:
Steve Waugh: 4
Mark Waugh: 3
ILLUSTRATION
Morae! Q
- Find a triplet such that triplet is minimum of all the triplets.
- Rearrange characters in a string such that no two adjacent are same.
- Return the coordinates of all cells in matrix sorted by their distance.
- Function to verify the ISBN number from the book.
- Find out the absolute difference of values of two array integers.
- Rotate the array in the right direction by K steps.
- Find the sequence of moves that wins the game, collect exactly G coins!.
- Calculate the sum of boundary elements of a matrix.
- Find the total number of ways to reach the tree house.
- Compute profit and loss of a product.
- Find the total expense of purchased items.
- Determine the maximum sequence weight.
- Find the person’s birth year is a leap year or not.
- Find the inner rating with the displayed rating.
- Find if angles are valid to form a triangle.
- Find out the winner of the game from the given statistics.
- Verify the tag to determine if one needs to arrest or allow the vehicle.
- Find the largest hexadecimal number.
- Group up all anagrams together from given words.
- Return all anagrams from the given words.