跳到正文

题解

题解:P14130 【MX-X22-T1】「TPOI-4A」MEX Problem

cgy20140502约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P14130

版本

  1. v2当前
  2. v1

读完题后不难发现,要让 mex⁡\operatorname{mex} 不为 00 的话区间里必须有一个 00,那么 00 的个数就是区间的个数。 code :

C++
#include <bits/stdc++.h>//华丽开头
using namespace std;
int n,a,ans;//记录个数,不需要开数组
int main(){
	cin >> n;
	for (int i = 1;i <= n;i++){
		cin >> a;
		if (a == 0) ans++;//有多少个0
	}
	cout << ans;
	return 0;//好习惯
}
原文