关注
蓝桥杯2024年第十五届省赛真题-握手问题

在这里插入图片描述
方法一:模拟

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int n=1e6;
int a,b[n],c;
signed main()
{
    for(int i=1;i<=50;i++)
    {
        for(int j=i+1;j<=50;j++)
        {
            if(i<=7&&j<=7)
            {
                continue;
            }
            c++;
        }
    }
    cout<<c<<endl;
}

方法二:高中计算
答案:
=所有人都两两握手的个数-7个人相互之间的握手的个数
=(49+48+…+1)-(6+5+…+1)
=50*49/2-7*6/2
=1204

转载自CSDN-专业IT技术社区

桂林电子科技大学 计算机与信息安全学院 蒋熹煜

原文链接:https://blog.csdn.net/qq_61735602/article/details/137997390

评论

赞0

评论列表

微信小程序
QQ小程序

关于作者

点赞数:0
关注数:0
粉丝:0
文章:0
关注标签:0
加入于:--