Take Three Jojo just graduated and moved up to grade 4. Today is his first day in...

90.2K

Verified Solution

Question

Programming

Take Three

Jojo just graduated and moved up to grade 4. Today is his firstday in 4th grade. Unfortunately, the lessons are held onlinebecause of pandemic. So that the quality of learning remains good,Jojo’s teacher gives a hard task for 4th grader. After the 4thgraders finished their first task which is prime factorization.Jojo’s teacher set up a game for the stundets. The game is verysimple. Given N colored balls, each student has to take 3 ballsrandomly. If a student got 3 balls with the same color, then thestudent counted as winner. Jojo is angry because he knows that thisgame is just pure luck to reach its goal. On the other hand, Jojowants to know the number of possibilities to get 3 balls with thesame color. As a good friend of Jojo, help Jojo to count the numberof possibilities to get 3 balls with the same color.

Format Input:

There are T testcases. Every testcase contains two rows. Thefirst row consists of one integer N which indicates the number ofballs. The second row consists of N integers A 1, A 2, A 3, ..., An where A i describes i-th ball’s color.

Format Output:

Output T line with format “Case # X: ”, where X indicates thetestcase number and then followed by an integer describes thenumber of possibilities to get 3 balls with the same color.

Constraints

• 1 ≤ T ≤ 10

• 3 ≤ N ≤ 10 5

• 1 ≤ A i ≤ 1000

Sample Input (standard input) :

5

5

1 1 2 2 2

5

1 2 2 2 2

10

1 3 3 3 3 3 2 2 2 2

5

1 2 2 3 3

10

2 2 2 2 2 2 2 2 2 2

Sample Output (standard output):

Case #1: 1

Case #2: 4

Case #3: 14

Case #4: 0

Case #5: 12

note : use C language, integer must be the same as theconstraint, DONT USE VOID/RESULT/QSORT, (the output must be thesame, print the \"Case..\" too)code it under int main (){

Answer & Explanation Solved by verified expert
3.9 Ratings (407 Votes)
include    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students