โจทย์
ดูฉบับแปล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.
เงื่อนไข
0 ≤ people ≤ 1,000,000,000. The answer fits a signed 64-bit integer.
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
people = 4
ผลลัพธ์ที่คาดหวัง:
expected = 6
อินพุต:
long long people = 4;
ผลลัพธ์ที่คาดหวัง:
long long expected = 6;
อินพุต:
long people = 4;
ผลลัพธ์ที่คาดหวัง:
long expected = 6;
คำอธิบาย
The pairs are AB, AC, AD, BC, BD, and CD: six handshakes.
ตัวอย่างที่ 2
อินพุต:
people = 1
ผลลัพธ์ที่คาดหวัง:
expected = 0
อินพุต:
long long people = 1;
ผลลัพธ์ที่คาดหวัง:
long long expected = 0;
อินพุต:
long people = 1;
ผลลัพธ์ที่คาดหวัง:
long expected = 0;
คำอธิบาย
One person has nobody else to greet.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน