Problem C
Time Limit : 6000/3000ms (Java/Other) Memory Limit : 131072/131072K (Java/Other)
Total Submission(s) : 92 Accepted Submission(s) : 25
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Definite an operation work$(Q,x)$ as sequence $Q$ from the first number on,keep the top $x$ numbers and delete followed $x$ numbers, keep the next $x$ numbers and delete followed $x$ numbers, then keep recycling this process.
$Q$ is the positive integer sequence, Given a sequence $A$, operating Work$(Q,A_{i})$ upon positive integer sequence output the nth member after $n$ operations.
$Q$ is the positive integer sequence, Given a sequence $A$, operating Work$(Q,A_{i})$ upon positive integer sequence output the nth member after $n$ operations.
Input
First line contains $T (T \leq 10)$ denoting the number of test cases.
$T$ cases follows. For each cases:
First line contains integer $n (0 < n \leq 10000)$, next line contains $n$ integers $A_{i} (0 < A_{i} \leq 1000)$ indicates the i-th operation.
$T$ cases follows. For each cases:
First line contains integer $n (0 < n \leq 10000)$, next line contains $n$ integers $A_{i} (0 < A_{i} \leq 1000)$ indicates the i-th operation.
Output
For each case output the answer in one line.
Sample Input
2 3 1 2 3 3 3 2 1
Sample Output
9 15