4 solutions

  • 1
    @ 2026-7-28 16:28:06
    #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;
    }
    
    
    • 0
      @ 2026-8-24 16:20:56
       #include<bits/stdc++.h>
      using namespace std;
      int n[1010],m[1010];
      int main()
      {
          int a,b,c=0;
          cin>>a>>b;
          for(int i=0;i<b;i++)
          {
              cin>>n[i];
              m[n[i]]=1;
          }
          for(int i=0;i<a;i++)
          {
              if(m[i]==0)
              {
                  cout<<i<<" ";
                  continue;
              }
              c++;
          }
          if(c==a)
          {
              cout<<a;
          }
          return 0; 
      }
      
      

      A0468A0468

      • 0
        @ 2026-7-9 15:35:04
        #include<bits/stdc++.h>
        using namespace std;
        int s1[1010]; 
        int main()
        {
            int n,m;
            bool b=true;
            cin>>n>>m;
            for(int i=1;i<=m;i++){
                int a;
                cin>>a;
                s1[a]=-1;
            }
            for(int i=1;i<n;i++){
                if(s1[i]!=-1) {
                    cout<<i<<' ';
                    b=false;
                }
            }
            if(b) cout<<n;
            return 0;
        }
        
        • 0
          @ 2026-6-20 13:42:03
           #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
          70
          Accepted
          27
          Uploaded By