2179 - I2P(I)2020_Hu_lab7 Scoreboard

Time

2020/11/23 18:40:00 2020/11/23 20:40:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12499 Pointer Integer Array
12989 Parentheses problem

12499 - Pointer Integer Array   

Description

(Partial Judge) Given a pointer integer array **ptr with size N, and an integer array *array with size (N+1)*N/2. Please use malloc function to allocate memory to **ptr and *array. The *array is an ascending sequence of number. Each pointer in array **ptr shall point to one element of *array where ptr[0] should point to array[0] and other ptr[i] should point to array[(i+1)*i/2] for all 0 < i < N.

For example, when n = 5, the size of **ptr will be 5, and the size of *array will be 15. The first pointer of **ptr is *ptr[0] which points to array[0], and the second pointer of **ptr is *ptr[1] which points to array[1], and the third pointer of **ptr is *ptr[2] which points to array[3], and the forth pointer of **ptr is *ptr[3] which points to array[6].

main.c

function.h

Input

The first line is size of **ptr

The second line is offset

0 <= offset < size <3000

Output

Print each pointer of *(*ptr + offset)

Note that you need to print a newline character ‘\n’ after each number, that is, just one number will be shown in each line of the output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12499.c

Partial Judge Header

12499.h

Tags




Discuss




12989 - Parentheses problem   

Description

Given a string which only contains '(' and ')' , you are asked to compute the value of the given string based on the following rules.

Supposed that A and B are both string which only contain '(' and ')'.

Rule 1: () = 1

Rule 2: (A) = 2 × A . For example, (()) = 2 × () = 2 × 1 = 2

Rule 3: AB = A + B . For example, ()() = 1 + 1 = 2

Computation process example:

Input string = (()(())) = 2 × ()(()) = 2 × [1 + (())] = 2 × [1 + 2 × ()] = 2 × [1 + 2 × 1] = 6

Notice: We guarantee that the given string is legal to compute. Therefore, testcases will not contain the following illegal cases.

illegal cases examples: ((), ))((

Input

First line contains an integer N which denotes the length of the given string. (2 ≤ N ≤ 100)

Second line contains N characters which denotes the input parentheses string.

Output

An integer which represent the value of the given string. (We guarantee that the answer can be stored in long long)

(Don't forget to print '\n' at the end of the line)

Sample Input  Download

Sample Output  Download

Tags




Discuss