cf1214B B. Badges

2023-05-16

							B. Badges
				time limit per test1 second
				memory limit per test512 megabytes
				inputstandard input
				outputstandard output

There are b boys and g girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and n participants have accepted the invitation. The organizers do not know how many boys and girls are among them.

Organizers are preparing red badges for girls and blue ones for boys.

Vasya prepared n+1 decks of badges. The i-th (where i is from 0 to n, inclusive) deck contains i blue badges and n−i red ones. The total number of badges in any deck is exactly n.

Determine the minimum number of decks among these n+1 that Vasya should take, so that there will be a suitable deck no matter how many girls and boys there will be among the participants of the tournament.

Input
The first line contains an integer b (1≤b≤300), the number of boys.

The second line contains an integer g (1≤g≤300), the number of girls.

The third line contains an integer n (1≤n≤b+g), the number of the board games tournament participants.

Output
Output the only integer, the minimum number of badge decks that Vasya could take.

Examples
input

5
6
3
output
4
input
5
3
5
output
4
Note
In the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).

In the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used.
题意: b个男生和g个女生去参加比赛,只有n个人可以参加,男生需要红色徽章,女生需要蓝色徽章,但不知道具体的参加比赛人数情况,问要准备多少种徽章方案,即问n个人中,男生和女生能组合的种类。
思路: 由于数据量很小,直接两重循环暴力求解即可。详情看代码。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int b, g, n;
	scanf("%d%d%d", &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++;
		}
	}
	printf("%d\n", ans);
	return 0; 
} 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cf1214B B. Badges 的相关文章

随机推荐

  • windows驱动开发-编译错误集合

    作者 QQ群 xff1a 852283276 微信 xff1a arm80x86 微信公众号 xff1a 青儿创客基地 B站 xff1a 主页 https space bilibili com 208826118 WDK7600 wdmgu
  • mac date命令详解

    文章目录 mac date 命令详解1 共同点2 不同点3 mac date 命令用法详解4 示例 mac date 命令详解 前言 xff1a Mac下date命令式BSD xff08 Berkeley Software Distribu
  • Word文档转PDF后文件变小、图片不清晰解决办法

    Word文档往往需要转成PDF文件 xff0c 如果文档中有图片 xff0c 转换之后在PDF中图片不清晰或者放大之后不清晰 xff08 根本原因是转PDF过程中对图片进行了压缩 xff09 xff0c 影响打印或者投稿 通过以下几步可以轻
  • VS2013/MFC 实现Windows资源管理器的简单方法

    开发平台 xff1a Win7 43 VS2013 总想用MFC来实现Windows系统下的一些小程序 xff0c 今天突然想实现Windows资源管理器 xff0c 发现一种非常简单的方法能够实现它 xff0c 主要用List Contr
  • OpenStack安装相关问题及解决方法

    OpenStack排错总结 1 AMQP Server on controller 5672 is unreachable 解决方法 xff1a iptables I INPUT p tcp dport 5672 j ACCEPT 2 un
  • WSL2迁移方法

    WSL是Windows下的Linux子系统 xff0c 可以代替虚拟机来运行Linux系统 xff0c 占用资源少 xff0c 使用方便 xff0c 下面说一下如何对已发布子系统进行迁移 一种情况是针对同一个系统 xff0c 更换安装的位置
  • 将Word 2010的公式转换成MathType公式

    现在越来越多的人在文档中编辑公式的时候会选择MathType来编辑 xff0c 因为它包含有众多的数学符号和模板 xff0c 编辑公式时非常方便 但是也有一些人在编辑公式时没有使用MathType公式编辑器 xff0c 直接使用Word中自
  • Paraview与VTK学习笔记(五)

    上一节最后执行到 xff1a this gt GetRenderWindow gt Render 也就是执行到了vtkRenderWindow Render 了 xff0c 我们可以看到这个函数是告诉这个RenderWindow下的每一个r
  • cf1214A A. Optimal Currency Exchange

    A Optimal Currency Exchange time limit per test1 5 seconds memory limit per test512 megabytes inputstandard input output
  • HTTP 413 Request Entity Too Large(Payload Too Large)

    原因 上传文件时 xff0c 请求参数过大 xff0c 导致超出服务端限制 客户端发送的实体主体部分比服务器能够或者希望处理的要大 解决 Nginx默认最大能够上传1MB文件 xff0c 打开nginx conf在http 中 xff0c
  • 常见服务默认端口

    服务端口FTP xff08 File Transfer Protocol xff0c 文件传输协议 xff09 21端口SSH xff08 Secure Shell Protocol xff0c 安全外壳协议 xff09 22端口Telne
  • linux环境下交叉编译arm架构jpeglib

    1 官网下载jpeglib源码 下载地址 http www ijg org 选择目前最新的版本jpegsrc v9c tar gz 2 配置 configure prefix span class token operator 61 spa
  • python批处理将图片进行放大实例代码

    最近处理一些规格不一的照片 xff0c 需要修改成指定尺寸便于打印 xff0c 本篇文章主要给大伙介绍关于Python批量处理将图片进行放大的相关资料 xff0c 文中通过实例代码介绍的非常详细 xff0c 需要的伙伴们可以参考下 pyth
  • 一些必不可少的Sublime Text 2插件

    中文原文 xff1a 一些必不可少的sublime text 2插件 整理自 xff1a Essential Sublime Text 2 Plugins and Extensions 请尊重版权 xff0c 转载请注明来源 xff0c 多
  • linux系统安装Confluence

    1 使用docker安装Confluence容器 docker run d name confluence p 8090 8090 user root root cptactionhank atlassian confluence late
  • Ubuntu 20.04 安装STM32开发环境 (Ubuntu+STM32CubeMX + Vscode+Makefile+Openocd)

    小记 xff1a 最近在学习I MX6U和Zynq比较多 xff0c 又都是在linux系统下 xff0c 然后又不想丢下STM32单片机 xff0c 所以就想到了可不可以在Ubuntu操作系统中编写STM32的代码 xff0c 来替代Wi
  • rust 介绍及开发环境配置(linux+windows)

    本文以windows或linux桌面作为开发环境 注意 xff1a rust需要c的编译器 rustup是官方的 xff0c 会安装cargo包管理 xff0c 这个cargo通常会伴随rust开发的全过程 一 介绍 官网链接 xff1a
  • 打开.data文件的步骤

    老师最近给了一组 data格式的文件 xff0c 当我直接强行改为 csv或者 xls文件再使用Python打开 xff0c 发现数据在Python中只有一列 xff0c 后面无法对数据进行索引 xff0c 在搜了一些方法后 xff0c 分
  • Week2 实验 A - 化学 Gym - 270437A

    题目 甄别烷烃基的类别 假设如上图 xff0c 这个烷烃基有6个原子和5个化学键 xff0c 6个原子分别标号1 6 xff0c 然后用一对数字 a b 表示原子a和原子b间有一个化学键 这样通过5行a b可以描述一个烷烃基 输入第一行为数
  • cf1214B B. Badges

    B Badges time limit per test1 second memory limit per test512 megabytes inputstandard input outputstandard output There