2 条题解

  • 1
    @ 2025-11-7 20:58:01
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int n,m;
        cin>>n;
        int nums[100000];  
        for(int i=0;i<n;i++)
            cin>>nums[i];
        cin>>m;    
        int first=0;
        int sums=0;    
        for (int i=0;i<n;i++){
            if(nums[i]==m){
                sums++;
                if(first==0){
                    first=i+1;
                }
            }
        }    
        cout<<first<<" "<<sums<<endl;  
        return 0;
    }
    • 0
      @ 2023-3-29 20:16:36

      纯查找

      #include<iostream>
      using namespace std;
      int a[100001],n,m,cnt,wz;
      int main(){
      	cin>>n;
      	for(int i=1;i<=n;i++)cin>>a[i];
      	cin>>m;
      	for(int i=1;i<=n;i++){
      		if(a[i]==m){
      			if(wz==0)wz=i;
      			cnt++;
      		}
      	}
      	cout<<wz<<" "<<cnt;
      	return 0;
      }
      
      • 1

      信息

      ID
      1019
      时间
      1000ms
      内存
      128MiB
      难度
      2
      标签
      递交数
      34
      已通过
      25
      上传者