Tap here to switch tabs
Problem
Submissions

Problem: Sum of Sortable Integers

Try to solve the Sum of Sortable Integers problem.

Statement

You are given an integer array nums of length n.

A positive integer k is a divisor of n (n(modk)=0n \pmod k = 0). Dividing nums into contiguous subarrays of length k, the integer k is called sortable if each subarray can be independently cyclically rotated such that the entire array becomes sorted in nondecreasing order.

Return the sum of all sortable integers k.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Sortable Integers

Try to solve the Sum of Sortable Integers problem.

Statement

You are given an integer array nums of length n.

A positive integer k is a divisor of n (n(modk)=0n \pmod k = 0). Dividing nums into contiguous subarrays of length k, the integer k is called sortable if each subarray can be independently cyclically rotated such that the entire array becomes sorted in nondecreasing order.

Return the sum of all sortable integers k.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5