문제
Author: Adrian Satja Kurdija
After successfully solving his math homework from the previous task, Mirko has become bored, so he has made a list of N large integers. On the list there are some pairs of numbers that he likes, and some pairs he doesn’t like. Mirko has named the pairs that he likes pals. Two numbers are pals if they have at least one digit in common (not necessarily in the same position). Help Mirko count how many pairs of numbers in his list are pals.
입력
The first line of input contains the positive integer N (1 ≤ N ≤ 1 000 000). Each of the next N lines contains a positive integer from the range [1, 1018], a number from Mirko’s list. No two numbers in the list will be equal.
출력
The first and only line of output must contain the number of pairs that are pals.
예제 입력 1
3
4
20
44
예제 출력 1
1
예제 입력 2
4
32
51
123
282
예제 출력 2
4
코드를 제출하려면 로그인이 필요합니다.
로그인