3 solutions

  • 6
    @ 2024-7-11 11:40:19
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	int s=0;
    	for(int i=1;i<=n;i++)
    	{
    		int t=i;
    		while(t)
    		{
    			if(t%10==1)
    			{
    				s++;
    			}
                t/=10;
    		}
    	}
    	cout<<s;
    	return 0;
    }
    
    • -3
      @ 2024-11-4 18:49:32
      ```cpp
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n, m = 0;
          cin>>n;
          for(int i = 1;i <= n;i++)
          {
              int a = i;
              while(a)
              {
                  if(a % 10 == 1)
                  {
                      m += 1;
                  }
                  a /= 10;
              }
          }
          cout<<m;
          return 0;
      }
      
      
      • -3
        @ 2024-7-11 11:45:07

        👍 👍

        • @ 2024-11-3 10:27:18

          👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍👍 👍

        • @ 2025-4-26 19:41:51

          @ 伪季

      • 1

      Information

      ID
      890
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      94
      Accepted
      49
      Uploaded By