#P11129. 【MX-X5-T1】「GFOI Round 1」Inverted World
【MX-X5-T1】「GFOI Round 1」Inverted World
Background
Original link: https://oier.team/problems/X5B。
Problem Description
Given a positive integer sequence of length , it is guaranteed that this sequence is an arithmetic progression。
(If you do not know the definition of an arithmetic progression, please refer to the hint at the end of the statement.)
Please find the number of non-empty contiguous subarrays () in this sequence that satisfy:
- The average of the elements in the subarray is an integer。
(That is, is an integer.)
The sequence may be very long, i.e., can be very large, so the full sequence will not be given. Instead, only the length , the first term , and the common difference are given. It is guaranteed that are both positive integers。
Input Format
This problem contains multiple test cases。
The first line contains a positive integer , representing the number of test cases。
For each test case:
The first line contains three positive integers 。
Output Format
For each test case, output one line containing a non-negative integer, representing the number of subarrays whose average is an integer。
3
2 1 2
3 2 5
11451 41 91981
3
4
32787076
Hint
[Sample Explanation]
In the first test case, 。There are non-empty contiguous subarrays that satisfy the requirement:
- , whose average is ;
- , whose average is ;
- , whose average is 。
In the second test case, 。There are non-empty contiguous subarrays that satisfy the requirement:
- , whose average is ;
- , whose average is ;
- , whose average is ;
- , whose average is 。
[Constraints]
| Test Point ID | Score | |||
|---|---|---|---|---|
For all testdata, it holds that , 。
[Definition Hint]
An arithmetic progression of length with first term and common difference is defined as and (for every )。
Translated by ChatGPT 5