【小米oj】 第一个缺失正数

本文介绍了一段使用C++实现的数据结构处理代码,包括宏定义、类型定义、全局变量声明以及主函数中对输入字符串进行处理的过程。代码利用istringstream进行字符串解析,并通过动态规划算法解决特定问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 #define mm(a) memset(a,0,sizeof(a));
 2 #define max(x,y) (x)>(y)?(x):(y)
 3 #define min(x,y) (x)<(y)?(x):(y)
 4 #define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
 5 #define rep(i,a,b) for(int i=(a);i<=(b);i++)
 6 #define per(i,b,a) for(int i=(b);i>=(a);i--)
 7 #include<bits/stdc++.h>
 8 typedef long long ll;
 9 #define PII pair<ll,ll>
10 using namespace std;
11 const int INF=0x3f3f3f3f;
12 const int MAXN=(int)2e5 + 5;
13 const ll mod=1e9+7;
14 
15 
16 string input,temp;
17 vector<int>v;
18 map<int,int>mp;
19 int n,dp[MAXN],m;
20 int main() {
21     while(cin>>input) {
22         istringstream iss(input);
23         mm(dp);
24         v.clear();
25         v.push_back(0);
26         while (getline(iss, temp, ',')) {
27             int x=atoi(temp.c_str());
28             v.push_back(x);
29             dp[x]=1;
30         }
31         int now=1;
32         while(dp[now])now++;
33         printf("%d\n",now);
34     }
35     return 0;
36 }

 

转载于:https://www.cnblogs.com/dogenya/p/10815655.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值