10405 - problem3   

Description

This is a problem about a hungry spider eating insects. You will be given a 5*5 board on which several fixed insects stay at some locations. You will also be given the insects’ weight and the spider’s initial weight. The spider will move to these specific locations to eat the insects by the following rules:

1.      If the weight of an insect is less than that of the spider, the spider can eat the insect and increase its weight by including the insect’s weight.

2.      If the weight of an insect is heavier than that of the spider, the spider will be scared so as to lose half of its weight.

3.      If the weight of an insect is equal to that of the spider, the spider will return to its initial weight.

After given N moves, calculate the spider's weight.

 

Note:

1.      The coordinate of the upper-left corner is (0,0).

2.      You don’t need to consider the case that the spider moves to same locations for multiple times.

 

You may use the following piece of code:

#include 
int main(void){

    int move,i,j;
    int map[5][5] = {0};
    float weight;

    for(i=0;i<5;i++)
        for(j=0;j<5;j++)
            scanf("%d",&map[i][j]);

    scanf("%f",&weight);
    scanf("%d",&move);

    /*your code*/

    printf("%.1f\n",weight);
    return 0;
}

Input

5*5 board

the initial weight of the spider

N (moves)

the destination coordinate after the first move

the destination coordinate after the second move

the destination coordinate after the Nth move

Output

The weight of the spider.

You should print the newline character at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss