Geeksforgeeks

Timer is Running

Given an array if ‘n’ positive integers, count number of pairs of integers in the array that have the sum divisible by 4.

**Input:**

The first line of the input contains a single integer **T**, denoting the number of test cases. Then **T** test case follows. Each test-case has two lines of the input, the first line contains an integer denoting the size of an array N and the second line of input contains N positive integers.

**Output:**

Print the number of pairs of integers in the array that have the sum divisible by 4.

**Constraints:**

1<=T<=100

1<=N<=100

1<=arr[]<=1000

**Example:**

**Input:**

2

5

2 2 1 7 5

5

2 2 3 5 6

**Output:**

3

4

**Explanation:**

Testcase 1: (2,2), (1,7) and(7,5) are the 3 pairs.

Testcase 2: (2,2), (2,6), (2,6), (3,5) are the 4 pairs.

Author: Sahil_Chhabra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Pathak1899 | 436 |

yashdip123 | 380 |

kirtidee18 | 377 |

ykaushik | 261 |

_saswata | 232 |

kirtidee18 | 1057 |

ykaushik | 733 |

aggarwalvatsal5 | 709 |

pmr_3689 | 570 |

harbilassingh | 530 |

blackshadows | 5456 |

Ibrahim Nash | 5450 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4823 |

Login to report an issue on this page.