1336 - I2P(I)2017_Chen_Hw4 Scoreboard

Time

2017/11/17 19:00:00 2017/11/27 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11678 Firework Show
11679 Flattening the Tree
11680 Big Mod

11678 - Firework Show   

Description

Writer : jjjjj19980806

Description : pclightyear

Kim Jong-un is the Chairman of the Workers' Party of Korea and supreme leader of North Korea. Recently, a group of firework makers are designing a fascinating firework show for the upcoming Day of the Sun. The makers create a total of n fireworks, each with a “beauty grade” ai. Fireworks with the same beauty grade are actually the same. Kim hopes the total beauty grade of the show to be exactly m (Do not disappoint him!). The makers wonder how many different kinds of shows meet the supreme leader’s demanding request.

Note : It is not necessary to use all n firework in a single show.

Input

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

Each testcase contains two lines :

The first line contains two integer n, m, representing the number of fireworks and the supreme leader's request.

The second line contains n integer ai, representing the beauty grade of each firework.

It is guaranteed that :

  • 1 ≤ T ≤ 10
  • 1 ≤ n ≤ 20
  • 1 ≤ m ≤ 50000
  • 1 ≤ ai ≤ 2000

Output

For each testcase, please output a line contains one integer represents the number of different kinds of shows that meet the supreme leader’s demanding request.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11679 - Flattening the Tree   

Description

Writer : jjjjj19980806

Description : pclightyear

In this problem, we want you to use an array A to implement a perfect binary tree (a kind of binary tree which all interior nodes have two children and all leaves have the same depth or same level.). Given the level order sequence of the tree, please output the sequence of number after the tree is flattened.

For example, a perfect binary tree with level order sequence 4 2 6 1 3 5 7 looks like : 

After flattening, so you should output 1 2 3 4 5 6 7.

 

Here is some tips for you guys to implement a binary tree.

1. A[1] is the root of the tree.

2. For the node locates in A[k], its left child locates in A[2k] and its right child locates in A[2k+1].

3. You can write a recursive function "find_seq" which takes the root index as its argument.

Input

The first line contains one integer n, representing the number of nodes in the tree.

The second line contains n integer ai, representing the level order of the tree.

It is guaranteed that :

  • n = 2k - 1
  • 1 ≤ k ≤ 10
  • a1 ~ an is a permutation of 1 ~ n

Output

Please output the sequence of the number after the tree is flattened. Each number is separated by a whitespace.

You need to print ‘\n’ at the end of the output.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




11680 - Big Mod   

Description

Writer : jjjjj19980806

Description : pclightyear

jjjjj doesn't like long description.

Given integers a, n, p, please calculate the value of an mod p.

Input

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

Each testcase contains a line with three integer anm.

It is guaranteed that :

  • 1 ≤ T ≤ 1000
  • 1 ≤ a, n, p ≤ 109

Output

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

Sample Input  Download

Sample Output  Download

Tags




Discuss