No-Divisible Range

AtCoder
IDabc435_b
Time2000ms
Memory256MB
Difficulty
You are given a sequence of positive integers $A=(A_1,A_2,\ldots,A_N)$ of length $N$. Find the number of pairs of integers $(l,r)$ satisfying $1\leq l\leq r\leq N$ that satisfy the following condition: > For every integer $i$ satisfying $l\leq i\leq r$, $A_i$ is **not** a divisor of $A_l+A_{l+1}+\cdots+A_r$. ## Constraints * $1 \leq N \leq 50$ * $1 \leq A_i \leq 1000$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
5
8 6 10 5 7
Output #1
6

We have $A=(8,6,10,5,7)$.
For example, $(l,r)=(1,2)$ satisfies the condition because $A_l+A_{l+1}+\cdots+A_r=A_1+A_2=14$, and neither $A_1=8$ nor $A_2=6$ is a divisor of $14$.  
On the other hand, $(l,r)=(1,3)$ does not satisfy the condition because $A_l+A_{l+1}+\cdots+A_r=A_1+A_2+A_3=24$, and $A_1=8$ is a divisor of $24$.
The pairs that satisfy the condition are $(l,r)=(1,2), (1,4), (2,3), (2,4), (3,5), (4,5)$, which is six pairs, so output $6$.
Input #2
3
1 1 1
Output #2
0
API Response (JSON)
{
  "problem": {
    "name": "No-Divisible Range",
    "description": {
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\ldots,A_N)$ of length $N$.   Find the number of pairs of integers $(l,r)$ satisfying $1\\leq l\\leq r\\leq N$ that satisfy the following conditi",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc435_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\ldots,A_N)$ of length $N$.  \nFind the number of pairs of integers $(l,r)$ satisfying $1\\leq l\\leq r\\leq N$ that satisfy the following conditi...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments