AtCoder Regular Contest 136
D
Without Carry
AtCoder
⌀ 1908
原题
← CE →
翻译中…

Problem Statement

翻译中…

You are given an integer sequence of length $N$: $A=(A_1,A_2,\cdots,A_N)$.

翻译中…

Find the number of pairs of integers $(i,j)$ ($1 \leq i < j \leq N$) such that calculation of $A_i+A_j$ by column addition does not involve carrying.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 10^6$
  • $0 \leq A_i \leq 10^6-1$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4
4 8 12 90
Output #1
3
The pairs $(i,j)$ that count are $(1,3),(1,4),(2,4)$. For example, calculation of $A_1+A_3=4+12$ does not involve carrying, so $(i,j)=(1,3)$ counts. On the other hand, calculation of $A_3+A_4=12+90$ involves carrying, so $(i,j)=(3,4)$ does not count.
Input #2
20
313923 246114 271842 371982 284858 10674 532090 593483 185123 364245 665161 241644 604914 645577 410849 387586 732231 952593 249651 36908
Output #2
6
Input #3
5
1 1 1 1 1
Output #3
10
题目信息
题号
arc136_d
时间限制
4 s
内存限制
1024 MB

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