Orig Description
Circular Sugoroku
Yuki made a sugoroku (Japanese board game similar to Snakes and Ladders) for the children's event so that everyone can play together. In this sugoroku, the squares are arranged in a circle, and each square has an integer greater than or equal to 1 written on it.
The player chooses a square as the starting point and places their piece there. Then, they move their piece clockwise according to the number written on the square. They repeat this process, moving clockwise according to the number written on the square they land on, until they reach the starting point again, at which point they win.
In reality, there may be cases where it is impossible to win, depending on which square the player chooses as their starting point. Yuki wants to count the number of squares from which it is possible to win.
Write a program that takes the information of a sugoroku as input and reports the number of squares from which it is possible to win.
Input
The input is given in the following format.
N
a1 a2 ... aN
The first line contains the number of squares N (1 ≤ N ≤ 100000) in the sugoroku. The second line gives the clockwise order of integers written on each square ai (1 ≤ ai ≤ 109).
Output
Print the number of squares from which it is possible to win.
Sample Input 1
3
1 1 1
Sample Output 1
3
Sample Input 2
3
1 1 2
Sample Output 2
2
Sample Input 3
8
2 3 7 3 3 3 4 4
Sample Output 3
6
Extracted Specification
An integer N (1 ≤ N ≤ 100000), representing some quantity or size.
A list of integers A of size N, where each integer is between 1 and 1e9.
### Example Input:
```
3
1 1 2
```
### Function Signature:
Write a function f(N, A) that takes in the input.
def f(N: int, A: List[int]):
'''
N: an integer
A: a list of integers
'''
Test Case Generator
Sure! Below is a test case generator for the given "Circular Sugoroku" problem. This generator will create random valid inputs according to the problem's constraints.
```python
import random
def tcgen():
# Number of squares N
N = random.randint(1, 100000)
# Values on each square a1, a2, ..., aN
A = [random.randint(1, 10**9) for _ in range(N)]
return N, A
# Example usage:
N, A = tcgen()
print(N)
print(" ".join(map(str, A)))
```
This function generates:
- `N`: A random integer between 1 and 100000, inclusive.
- `A`: A list of `N` integers, each between 1 and 10^9, inclusive.
### Explanation:
1. **N**: The number of squares in the sugoroku board is generated randomly within the specified range (1 to 100000).
2. **A**: The list comprehension generates `N` integers where each integer is randomly chosen within the range 1 to 10^9.
### Example Output:
The output of running the `tcgen()` function might look like:
```
5
123456789 987654321 123456789 987654321 123456789
```
This can be directly used as input for the problem statement.
### Additional Notes:
- This generator creates a wide variety of test cases, including edge cases where `N` is at its minimum or maximum value.
- Each generated test case adheres to the constraints provided in the problem statement.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
A = list(map(int, fh.readline().strip().split()))
return N, A