Submit | All submissions | Best solutions | Back to list |
IITKWPCH - Find Number Of Pair of Friends |
You are given n numbers. Any two number are called friends if they have some digit common. eg. (11, 12) and (15, 4561) are friends but (33, 556) are not.
Find out the number of pairs which are friends.
(Formally speaking let us suppose the n numbers are stored in array a[]. You have to find out number of i and j pairs such that i < j and a[i] and a[j] are friends.)
Input
T : number of test cases (1 ≤ T ≤ 7)
For each test case, you will be given two lines, first line will contain n <= 106, then the next line will contain n integers representing a[i] (1 ≤ a[i] ≤ 1018.)
Output
For every test case print a line containing number of such pairs as mentioned in the problem statement.
Example
Input: 4 2 12 13 3 10 12 24 3 5 6 7 4 10 11 211 3 Output: 1 2 0 3
Added by: | praveen123 |
Date: | 2013-08-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | general problem |
hide comments
|
||||||
2013-09-11 07:05:33 nitish rao
@praveen123 can you plz check my sol. um getting WA.. :( sol-id:9929488 got AC :) Last edit: 2013-08-28 10:04:51 |
||||||
2013-09-11 07:05:33 Hitman
Learnt something new |
||||||
2013-09-11 07:05:33 P_Quantum
Nice Question... :) |