Einfach 0 gelöst 0% Erfolgsquote

Count Handshakes

Count handshakes when every pair of people shakes hands once.

Every person shakes hands once with every other person. A handshake between A and B is the same event as one between B and A. Nobody shakes their own hand.

Implement handshake_count(people).

Input

people: The number of people.

Output

Return the total number of distinct handshakes.

Einschränkungen

0 ≤ people ≤ 1,000,000,000. The answer fits a signed 64-bit integer.

Beispiele

Beispiel 1
Eingabe:
people = 4

Erwartete Ausgabe:
expected = 6
Eingabe:
long long people = 4;

Erwartete Ausgabe:
long long expected = 6;
Eingabe:
long people = 4;

Erwartete Ausgabe:
long expected = 6;

Erläuterung

The pairs are AB, AC, AD, BC, BD, and CD: six handshakes.

Beispiel 2
Eingabe:
people = 1

Erwartete Ausgabe:
expected = 0
Eingabe:
long long people = 1;

Erwartete Ausgabe:
long long expected = 0;
Eingabe:
long people = 1;

Erwartete Ausgabe:
long expected = 0;

Erläuterung

One person has nobody else to greet.

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.