CF1895C.Torn Lucky Ticket
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A ticket is a non-empty string of digits from 1 to 9 .
A lucky ticket is such a ticket that:
- it has an even length;
- the sum of digits in the first half is equal to the sum of digits in the second half.
You are given n ticket pieces s1,s2,…,sn . How many pairs (i,j) (for 1≤i,j≤n ) are there such that si+sj is a lucky ticket? Note that it's possible that i=j .
Here, the + operator denotes the concatenation of the two strings. For example, if si is 13, and sj is 37, then si+sj is 1337.
输入格式
The first line contains a single integer n ( 1≤n≤2⋅105 ) — the number of ticket pieces.
The second line contains n non-empty strings s1,s2,…,sn , each of length at most 5 and consisting only of digits from 1 to 9 .
输出格式
Print a single integer — the number of pairs (i,j) (for 1≤i,j≤n ) such that si+sj is a lucky ticket.
输入输出样例
输入#1
10 5 93746 59 3746 593 746 5937 46 59374 6
输出#1
20
输入#2
5 2 22 222 2222 22222
输出#2
13
输入#3
3 1 1 1
输出#3
9