Problème
Afficher la traductionEvery 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.
Contraintes
0 ≤ people ≤ 1,000,000,000. The answer fits a signed 64-bit integer.
Exemples
Entrée :
people = 4
Sortie attendue :
expected = 6
Entrée :
long long people = 4;
Sortie attendue :
long long expected = 6;
Entrée :
long people = 4;
Sortie attendue :
long expected = 6;
Explication
The pairs are AB, AC, AD, BC, BD, and CD: six handshakes.
Entrée :
people = 1
Sortie attendue :
expected = 0
Entrée :
long long people = 1;
Sortie attendue :
long long expected = 0;
Entrée :
long people = 1;
Sortie attendue :
long expected = 0;
Explication
One person has nobody else to greet.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.