Files
lanqiao/15lanqiao/test1-1.cpp
2025-03-14 22:39:32 +08:00

15 lines
475 B
C++
Raw 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.
#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)
*/