A - Nastya Is Buying Lunch
B - Neko Performs Cat Furrier Transform
C - TV Shows
D - Pairs
E - Increasing by Modulo
F - Good Triple
G - The Tag Game
H - Money Transfers
I - Mahmoud and Ehab and the MEX
题意:给你一个大小为n的集合,里面有0~100以内的数字,然后你要保证集合里缺少的数字为x。有插入和删除的操作,问你最少需要几步的操作。
思路:非常简单。不需要说明什么。就是读题有点久。
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<set> #include<string> #include<vector> #include<ctime> #include<stack> #include<fstream> #include<iomanip> #include<deque> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mm(a,b) memset(a,b,sizeof(a)) #define maxn 2*500000+50 #define len 150000000+5 #define inf 0x3f3f3f3f int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a%b); } int main() { int n, x; int cnt[150] = {0}; scanf("%d %d", &n, &x); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); cnt[a]++; } if (x == 0) { printf("%d\n", cnt[0]); } else { int ans = 0; for (int i = 0; i < x; i++) { if (cnt[i] == 0) ans++; } ans += cnt[x]; printf("%d\n", ans); } return 0; }
J - Vitya and Strange Lesson
原文地址:https://www.cnblogs.com/Tangent-1231/p/11134610.html
时间: 2024-10-05 05:04:38