AtCoder Beginner Contest 164
D
Multiple of 2019
AtCoder
⌀ 1232
原题
← CE →
翻译中…

Problem Statement

翻译中…

Given is a string $S$ consisting of digits from 1 through 9.

翻译中…

Find the number of pairs of integers $(i,j)$ ($1 ≤ i ≤ j ≤ |S|$) that satisfy the following condition:

翻译中…

Condition: In base ten, the $i$-th through $j$-th characters of $S$ form an integer that is a multiple of $2019$.

翻译中…

Constraints

翻译中…
  • $1 ≤ |S| ≤ 200000$
  • $S$ is a string consisting of digits from 1 through 9.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

S

翻译中…

Output

翻译中…

Print the number of pairs of integers $(i,j)$ ($1 ≤ i ≤ j ≤ |S|$) that satisfy the condition.

翻译中…

样例

Input #1
1817181712114
Output #1
3
Three pairs - $(1,5)$, $(5,9)$, and $(9,13)$ - satisfy the condition.
Input #2
14282668646
Output #2
2
Input #3
2119
Output #3
0
No pairs satisfy the condition.
题目信息
题号
abc164_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。