SOLVE

LATER

Vanya and Students 3rd time around

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 ?

Table : **Students**

Field | Type |
---|---|

Name | text |

ID | text |

Height | int |

Name | ID | Height |
---|---|---|

Micro | 12abcd | 2 |

Vasya | 13abcd | 3 |

Rhezo | 14abcd | 4 |

answer |
---|

26 |

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 Database

Initializing Code Editor...

{"8e97c83": "/pagelets/show-submission/sql/vanya-and-students-3rd-time/", "8e97ced": "/pagelets/recommended-problems/sql/vanya-and-students-3rd-time/", "8e97cac": "/pagelets/suggested-problems/sql/vanya-and-students-3rd-time/", "8e97cd9": "/pagelets/problems-hint/sql/vanya-and-students-3rd-time/", "8e97cc4": "/pagelets/problem-author-tester/sql/vanya-and-students-3rd-time/"}

{}

realtime.hackerearth.com

80

1823cefa54ef789e19691df06d2004b30b912e71

58a29e5cae2309f04b28

/realtime/pusher/auth/