Search⌘ K

Solved Problem - PnC

Explore how to determine the number of ways to choose two balls of different types using combinations. Understand the approach of subtracting same-type pairs from total pairs and learn about efficient implementation suitable for large inputs.

We'll cover the following...

Problem statement

There are NN different types of balls. There are k1k_1 balls of type 1, k2k_2 balls of type 22, and so on to knk_n. How many ways can you choose 22 balls that are of different types?

Input format

The first line contains one positive integer N (1N105)(1 \leq N \leq 10^5) ...