All Tracks Problem

Vanya and Students 3rd time around
Tag(s):

Easy, math, 简单, 簡単

Problem
Editorial
Analytics

Vanya is extremely curious about the characteristics of her students. She has for each student of her class 3 pieces of information, i.e. their Name, ID and Height. Today, she has decided to play another game with her class. So, the rules of the game are :

This game consists of many turns. In each turn Vanya randomly picks any 2 students of her class. She then notes down on a piece of paper she has, the product of the heights of the 2 students.

She considers each pair of students only and exactly once. That is if Vanya has already written on the piece of paper the product of heights of 2 students \((i,j)\), then she will not write it again.

She continues this procedure until each distinct pair of students has been considered. That is, if there are N students studying in Vanya's class, then all valid pairs \((i,j)\) shall be :

\( \forall_{i=1}^{N-1} \forall_{j=i+1}^{N} (i,j)\)

Two Pairs \((i,j)\) and \((k,l)\) are considered to be distinct if \((i \ne k)\) or \((i \ne l)\) or \((j \ne k)\) or \((j \ne l)\).

Now, she wonders what is the sum of all the numbers written on this paper. Can you help her out ?

Input Format:

Table : Students

Field Type
Name text
ID text
Height int

Sample:

Name ID Height
Micro 12abcd 2
Vasya 13abcd 3
Rhezo 14abcd 4

Output:

answer
26

Constraints:

The number of students shall not exceed 20.

The height of each student shall lie between 1 and \(10\) inclusive.

The length of Name and ID of each student shall lie between 1 and \(20\) inclusive.

Explanation

For the sample,

The unique pairs of students are :

1.>(Micro, Vasya). Product=\((2 \times 3)\) = 6.

2 .> (Micro, Rhezo). Product= \((2 \times 4)\) = 8.

2 ,> (Vasya, Rhezo) . Product = \((3 \times 4)\) = \(12\).

Thus, the answer = \(6+8+12\)=\(26\).

Time Limit: 5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: MySQL, PostgreSQL, MSSQL, Oracle_Db

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications

?