1527 - I2P (I) 2018_Chen_hw3 Scoreboard

Time

2018/10/15 13:00:00 2018/10/25 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11567 Hexadecimal to Binary
11606 Factor Counter
11632 I2P_EECS_MID1_1

11567 - Hexadecimal to Binary   

Description

Please try to add 2 hexadecimal numbers,  and give the answer as binary number.

 

EX: Given A and B, we know that A represents 10 and B represents 11 in decimal, 10 + 11 = 21.

21 is 10101 in binary form , so the answer is 10101.

 

Hint: You can use %x to read hexadecimal numers :)

 

(Reference) Below is Acsii Table:

Input

Two hexadecimal numbers X and Y.

Output

The sum of X and Y in binary form.

Sample Input  Download

Sample Output  Download

Tags

:) 11567 peko AHOY



Discuss




11606 - Factor Counter   

Description

Given an interval [L,R], please find out the integer which has the most positive factors (正因數) in this interval.

If there are multiple answers, print the smallest of them.

Input

The first line contains an integer T, representing the number of testcases.

The next T lines contain two integers L and R, representing the endpoints of the interval.

  • 1 ≤ T ≤ 20
  • 1 ≤ L ≤ R ≤ 20000

Output

For each testcase, please output a line contains an integer representing your answer.

(i.e. Please print '\n' after each answer.)

Sample Input  Download

Sample Output  Download

Tags

:) :( >< :D :G konpeko



Discuss




11632 - I2P_EECS_MID1_1   

Description

Now you are in the World of Tanks !!!

 

Your mission is to follow the instructions and pick the coins : )

You will get a map of the world like this:

               

 

 is your tank with size 3x3 (xox is the head of the tank), and $ represents a coin, # represents the wall, ^ represents the hill.

If your tank (3x3 body) is above the $, you will pick it up ($ can't be counted again). If # or ^ is in front of the tank (in front of the xox, tank's front part), you can not move. Coins' position does not overlap initial tank's position.

The tank has four forward directions (South, East, North, West). Its direction is where xox heads. Notice that the upper of the map is the North, and the initial direction of the tank is not always North.

And you will receive a sequence of instructions, which contains (takes a step along the tank's head direction), (tank's head turns right), and (tank's head turns left). Instructions like R and L only change tank's head direction, and don't affect the tank's position (would not cause moving). 

Your mission is to receive the instructions and drives the tanks in order to collect coins, and report the amount of coins you get in the end.

Notice: The sample input in the below seems not aligned because the size of each character is not identical. You can see the map above (it is the same as sample input) if you want to see clearly.

 

P.S: Kind professor HT Chen asks TA to give students a code template. You can follow codes below to just finish 5 functions above the main(), and you don't need to change any content in the main(). Or you can decide to write whole codes by yourself, it's up to you :)

 

#include <stdio.h>
#include <string.h>

#define EAST 0
#define SOUTH 1
#define WEST 2
#define NORTH 3

char map[100][100];
char actions[100]={};
int coin_amount = 0;

// tank's initial direction
char init_dir;
// tank's direction now
int dir_now;
// tank's center x and y
int center_x, center_y;

void decide_initial_direction()
{
    /// Decide tank's initial direction
    /// Using init_dir
    /// To determine dir_now

 

}

void take_a_step()
{
    if (dir_now == NORTH){
        /// Detect wall first
        if ( ??? ){

        }
        /// And then detect hill
        else if (( ??? )) {

        }
        /// If there is no obstacle, take a step
        else {

        }
    }
    else if (dir_now == SOUTH){

    }
    else if (dir_now == EAST){

    }
    else if (dir_now == WEST){

    }
}

void pick_the_coins()
{
    int j, k;
    for (j = center_x - 1; j <= center_x + 1; j++){
        for (k = center_y - 1; k <= center_y + 1; k++){
            /// determine whether there are coins under the tank

 

        }
    }
}

void turn_right()
{
    /// Change direction depending on dir_now
}

 

void turn_left()
{
    /// Change direction depending on dir_now
}

int main()
{
    int i, j, k, rows, cols;
    int actions_number;
    int component = 0;

    /// Raed problem's input
    scanf("%d %d %d %c", &rows, &cols, &actions_number, &init_dir);
    while (getchar() != '\n');
    for (i = 0; i < actions_number; i++){
        scanf("%c", &actions[i]);
    }

    /// Read map
    for (i = 1; i <= rows; i++){
        while (getchar() != '\n');
        for (j = 1; j <= cols; j++){
            scanf("%c", &map[i][j]);
            /// Find tank's center x and y
            if (((map[i][j]) == 'x') || ((map[i][j]) == 'o') || ((map[i][j]) == 'O')){
                component++;
                if (component == 5){
                    center_x = i;
                    center_y = j;
                }
            }
        }
    }

    decide_initial_direction();

    for (i = 0; i < actions_number; i++){
        if (actions[i] == 'F'){
            take_a_step();
            pick_the_coins();
        }
        else{
            if (actions[i] == 'R'){
                turn_right();
            }
            if (actions[i] == 'L'){
                turn_left();
            }
        }
    }

    printf("%d\n", coin_amount);

    return 0;
}

 

 

 

Input

The first line of the input contains four things: 

1. The rows of the map (0 < rows < 100)

2. The columns of the map (0 < cols < 100)

3. The total length of instructions (0 < instructions's length < 100)

4. The initial tank's direction (N, E, S, W)

The second line is the content of instructions.

For the next lines, they illustrate the map.

Output

The number of coins you get. (printf "\n" in the end)

Sample Input  Download

Sample Output  Download

Tags




Discuss