525 - 競程 CPE 班 (2013/10/17) Scoreboard

Time

2013/10/17 19:00:00 2013/10/17 22:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
9008 Encryption
9009 Partial Sum

9008 - Encryption   

Description

We can encrypt a string into other string.  One method is to put a string into an n×n array first, where n is the smallest number such that n2 is equal to or larger than the length of the string.  Each character is put into a cell of the array, from the top left cell of the array and along neighboring cells in the counterclockwise order.  The encrypted string is the output of the row major order.  For example, the input string "Greed is good", whose length is 13, are put into a 4×4 array, as shown in the following figure.

The output string is "Googrd  e  sed i".

If the end of the encrypted string are spaces, don't output them.  For example, the output of "Bass GG" is "B Ga Gss".

Input

The input consists of multiple lines.  Each line is a test case, a string S with length <= 1000.  The number of test case is less than 100.

Output

For each test case, output the encrypted string of S.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9009 - Partial Sum   

Description

Given n integers and q queries, in which each query defines a range, find the sum of the n given integers within this range.

Input

The first line contains an integer t(1<=t<=20), which indicates the number of test cases. In each test case, the first line contains an integer n (n<=105), specifying how many integers will be given. The next line contains n integers, in which the ith integer represents ai (-50000 <= ai <= 50000). The followed line contains a positive integer q (q <= 104), denoting the number of queries. Next q lines define q queries, one per line. Each query is specified by two integers a and b(1<=a<=b<=n), meaning a range, in which the partial sum of the given integers are queried.

Output

For each query, output a line with the partial sum of the given integers within the queried range.

Sample Input  Download

Sample Output  Download

Tags




Discuss