#abc367d. D - Pedometer
D - Pedometer
Score : points
问题陈述
湖边有 个休息区。 休息区按顺时针方向编号为 , , ..., 。 从休息区 顺时针走到休息区 (其中休息区 指的是休息区 )需要 步。 从休息区 顺时针走到休息区 ()所需的最少步数是 的倍数。 找出可能的 对数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are rest areas around a lake.
The rest areas are numbered , , ..., in clockwise order.
It takes steps to walk clockwise from rest area to rest area (where rest area refers to rest area ).
The minimum number of steps required to walk clockwise from rest area to rest area () is a multiple of .
Find the number of possible pairs .
Constraints
- All input values are integers
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4 3
2 1 4 3
Sample Output 1
4
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is not a multiple of .
- The minimum number of steps to walk clockwise from rest area to rest area is , which is a multiple of .
Therefore, there are four possible pairs .
Sample Input 2
2 1000000
1 1
Sample Output 2
0
Sample Input 3
9 5
9 9 8 2 4 4 3 5 3
Sample Output 3
11