2 solutions

  • 1
    @ 2026-9-2 20:25:20
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,x,s=1;
    	cin>>n>>x;
    	for(int i=1;i<=n;i++)
    	{
    		int t=i;
    		while(t)
    		{
    			int ge=t%10;
    			if(ge==x)
    			{
    				s++;
    			}
    			t=t/10;
    		}
    	}
    	cout<<s-1;
        return 0;
    }
    
    • 0
      @ 2025-7-11 11:13:46
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n,m,k=0;
      	cin>>n>>m;
      	for(int i=1;i<=n;i++){
      		int t=i;
      		while(t){
      			if(t%10==m){
      				k++;
      			}
                  t/=10;
      		}
      	}
      	cout<<k;
      	return 0;
      }
      
      
      • 1

      Information

      ID
      2847
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      1
      Tags
      # Submissions
      62
      Accepted
      38
      Uploaded By