P12785 [HackerEarth] mehta and the tricky triplets
普及
题目描述

Mehta is a forever alone and desperate guy. He has a crush on N girls of his society. He wants to impress them all and so he needs to do their task collectively.All the girls give him a number which he stores in an array named A of size N. To do their task, he has to report the number of triplets (i,j,k) in the array A, with i < j < k such that the triplets have at least one prime digit in common.

Input & Output:
The first line of the input contains an integer N. The next N lines has a number on each, which denote the array A.

You need to print on one line, the number of triples with the condition mentioned in the problem statement.

Constraints:

1 ≤ N ≤ 10 ^ 5
0 ≤ A[i] ≤ 10 ^ {18} for all index i in the array A.

Sample Input:

5
21
22
23
24
25

Sample Output:
10

SAMPLE INPUT
5
21
22
23
24
25

SAMPLE OUTPUT
10

Explanation

In the given sample each i,j,k has one prime digit common that is 2. So, total triplets are 5C3 which is 10.

输入格式

见题面

输出格式

见题面

样例输入
5 21 22 23 24 25 SAMPLE
样例输出
10