Wcipeg 2017-2018 Test

Carol Economy

The Carol Economy is a set of people who interact and share hearts (<3) with each other. In order to be part of the Carol Economy, each person must be friends with every other person. Carol is trying to set up a larger Carol economy between some of her friends. There are N people, and K pairs of people know each other. Help Carol calculate the amount of new friendships that must be made.

Input Format:

The first line of input contains the integers N (1 ≤ N ≤ 1000) and K (0 ≤ K ≤ 106).

Output Format:

Output the number of new friendships that must be made. This number is guaranteed to be non-negative.

Sample Input:

10 8

Sample Output:

37

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 256M
Added: Dec 05, 2017
Authors: imaxblue, kxoraxe

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

[removed]

Please avoid giving away the solution in a comment.


Yes, there is a formula that can be used to calculate the number of unique pairs in a group of N members.