Files
lanqiao/15lanqiao/test1-1.cpp
2025-03-19 14:29:15 +08:00

16 lines
505 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// lanqiao 19695 握手问题
#include<bits/stdc++.h>
using namespace std;
int main() {
int tot = (50*49) / 2, cnt = (7*6) / 2;
cout << tot - cnt << endl;
return 0;
}
/*
总共有50人参与会议如果按照常规情况即每个人与除了自己以外的所有人各握手一次
握手总数tot=49+48+...+1=(50*49)/2
现在有7个人没有互相握手这7这个人本来应该握手的次数 cnt=6+5+...+1=(7*6)/2
实际握手次数=总的握手次数tot-7人的情况cnt (tot - cnt)
*/