#C10506. Count Unique Devices

    ID: 39719 Type: Default 1000ms 256MiB

Count Unique Devices

Count Unique Devices

You are given multiple test cases. In each test case, the first line contains an integer \(n\) representing the number of readings. The next line contains \(n\) integers, each denoting a device reading. The input terminates with a test case where \(n = 0\), which should not be processed.

Your task is to compute the number of unique device readings for each test case. Formally, for a test case with readings \(a_1, a_2, \dots, a_n\), you need to find \(|\{a_1, a_2, \dots, a_n\}|\), where \(|S|\) denotes the cardinality of set \(S\).

inputFormat

The input is read from standard input (stdin) and consists of multiple test cases. For each test case:

  • The first line contains an integer (n) ((n \geq 0)), the number of readings.
  • The second line contains (n) space-separated integers representing the device readings.

The input is terminated by a line containing a single 0.

outputFormat

For each test case (except the terminating case where (n = 0)), output a single line with one integer: the number of unique device readings from that test case, printed to standard output (stdout).## sample

10
1 2 1 2 2 3 1 2 3 3
5
4 4 4 5 5
0
3

2

</p>