#d1605. Ayoub's function
Ayoub's function
Ayoub's Function
Problem Description
Define the function , where is a 01 string, as the number of substrings of that contain at least one 1.
You are given a string with length and exactly 1s. Find the maximum possible value of .
Input Format
The input consists of multiple test cases.
The first line contains an integer (), the number of test cases.
Each of the next lines contains two integers (, ).
Output Format
Output lines, each containing one integer: the answer.
Sample Input
5
3 1
3 2
3 3
4 0
5 2
Sample Output
4
5
6
0
12
Sample Explanation
First test case: when , .
Second test case: when , .
Third test case: when , .
Fourth test case: when , .
Fifth test case: when , .