4 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=1010; int b[N]; int main() { int n,m; cin>>n>>m; for(int i=1;i<=m;i++) { int x; cin>>x; b[x]=1; } int cnt=0; for(int i=0;i<n;i++) { if(b[i]==0) { cout<<i<<" "; cnt=1;//表示至少有一个人没有出现过 } } if(cnt==0) //所有人都出现了 { cout<<n; } return 0; } -
-1
#include<bits/stdc++.h> using namespace std; int a[1010],b[1010]; int main() { int e,f; cin>>e>>f; int e1=0; for(int i=0;i<f;i++) { cin>>b[i]; a[b[i]]=1; } for(int j=0;j<e;j++) { if(a[j]==0) { cout<<j<<" "; } if(a[j]==1) { e1++; } if(e1==e) { cout<<e; return 0; } } return 0; //看过的请给我点👍 }
- 1
Information
- ID
- 1180
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 65
- Accepted
- 24
- Uploaded By