# Good triplets OA 2019

Given an array A of N integers. Find the number of good triplets (i, j, k), where i, j, k are all distinct indices such that 0 < i , j , k <= N. A good triplet (i, j, k) is a triplet such that the sum, S = A[i] + A[j] + A[k], is divisible by exactly one of A[i], A[j], or A[k].

Array values of a triplet (i,j,k) is (A[i], A[j], A[k]).

input: N=4 A=[1,2,2,1]

output: 12

Explanation : S=2+2+1=5 is divisible only by number 1 in the triplet and the triplet with array values 1, 1, 2 is not a good triplet as S = 4 is divisible by all three. So there are two triplets (1,2,2) and (2,2,1). Look at the i,j,k values which are indices. So, there are 12 possibilities of triplets of indices that can have array values as 2, 2, 1. They are:

(1, 2, 3), (1, 3, 2), (2, 1, 3), (3, 1, 2), (2, 3, 1), (3, 2, 1), (2, 3, 4), (2, 4, 3), (3, 2, 4), (4, 2, 3), (3, 4, 2), (4, 3, 2).
{"ft_lang_label":"__label__en","ft_lang_prob":0.8465391,"math_prob":0.9998859,"size":863,"snap":"2022-40-2023-06","text_gpt3_token_len":354,"char_repetition_ratio":0.13853317,"word_repetition_ratio":0.0,"special_character_ratio":0.4611819,"punctuation_ratio":0.27915195,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9986377,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-10-02T10:53:51Z\",\"WARC-Record-ID\":\"<urn:uuid:520c5252-83d4-4870-974f-05e890acf03c>\",\"Content-Length\":\"14056\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cfe32a52-15ce-47fe-aad0-7afb1e4211b2>\",\"WARC-Concurrent-To\":\"<urn:uuid:5a544115-4f40-41b3-902b-530e96aae80d>\",\"WARC-IP-Address\":\"159.65.103.148\",\"WARC-Target-URI\":\"https://1o24bbs.com/t/topic/14488\",\"WARC-Payload-Digest\":\"sha1:NNSYV45SG4CGYAOQ3SA3HVJU6KBFQWVM\",\"WARC-Block-Digest\":\"sha1:KPFEMVO6MKHDE3BRAAGIGPSGFVAC4XET\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030337307.81_warc_CC-MAIN-20221002083954-20221002113954-00029.warc.gz\"}"}