【CodeForce】1214B Badges

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/a342500329a/article/details/100556186

题目链接:http://codeforces.com/problemset/problem/1214/B
题意:b个男生和g个女生去参加运动会,只有n个人可以参加,男生需要红色徽章,女生需要蓝色徽章,求要准备多少种徽章方案,即n个人中,男女生有多少种组合。
直接暴力枚举就行

#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
using namespace std;

int main()
{
    int b, g, n;
    cin >>b>>g>>n;
    int ans=0;
    for(int i=0;i<=b;i++)
        for(int j=0;j<=g;j++){
            if(i+j==n)ans++;
        }
    cout<<ans;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/a342500329a/article/details/100556186
今日推荐