Codeforces 862A Mahmoud and Ehab and the MEX
来源:互联网 发布:mac air怎么截屏 编辑:程序博客网 时间:2024/06/05 05:06
题目链接:CF-862A
每日一水题,健康一辈子。
求一个含有n个非负整数的集合的mex,其中mex定义为该集合中没有出现的最小非负整数。其中有对集合有两种合法操作,一种是添加某个非负整数,一种是删除某个非负整数,问最小操作数可以使得集合的mex=x。
注意特判mex=0。
#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <cstdio>#include <algorithm>#include <string>#include <string.h>using namespace std;int main(){int n, mex;scanf("%d%d", &n, &mex);bool temp[105];memset(temp, false, sizeof(temp));for (int i = 0;i < n;++i){int v;scanf("%d", &v);temp[v] = true;}if (mex > 0){int ans=0;for (int i = 0;i < mex;++i){if (!temp[i])ans++;}if (temp[mex])ans++;printf("%d\n", ans);}else{if (temp[0])printf("1\n");elseprintf("0\n");}//system("pause");return 0;}
阅读全文
0 0
- codeforces 862A Mahmoud and Ehab and the MEX
- codeforces 862A Mahmoud and Ehab and the MEX
- Codeforces 862A Mahmoud and Ehab and the MEX
- codeforces 862A 之 Mahmoud and Ehab and the MEX
- CodeForces 862A Mahmoud and Ehab and the MEX
- Codeforces Round #435 A. Mahmoud and Ehab and the MEX
- Codeforces Round #435 A. Mahmoud and Ehab and the MEX
- Codeforces --- Mahmoud and Ehab and the MEX
- A. Mahmoud and Ehab and the MEX
- 862A. Mahmoud and Ehab and the MEX
- 862A Mahmoud and Ehab and the MEX (水)
- CF 862A. Mahmoud and Ehab and the MEX
- Codeforces Round #435 (Div. 2) A. Mahmoud and Ehab and the MEX(思路)
- Mahmoud and Ehab and the MEX
- Mahmoud and Ehab and the xor CodeForces
- Mahmoud and Ehab and the bipartiteness CodeForces
- Mahmoud and Ehab and the xor CodeForces
- codeforces Mahmoud and Ehab and the bipartiteness
- 渗透测试工具sqlmap基础教程
- C语言里的strcpy()
- 网络安全之VPN详解
- spring中@param和mybatis中@param使用区别
- connect方法分析
- Codeforces 862A Mahmoud and Ehab and the MEX
- POJ3670 Eating Together 【动态规划】【LIS模板】
- spark的几个示例
- java8 不使用循环
- 20170920--navicat测试
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Python函数参数默认值的陷阱和原理深究
- RecycleView刷新加载
- 初识410c