7 条题解

  • 4
    @ 2023-9-26 15:11:36

    暴力法,直接数位拆分

    #include <iostream>
    using namespace std;
    bool check(int n)
    {
        while(n)
        {
            if (n % 10 == 5)
                return true;
            n /= 10;
        }
        return false;
    }
    int main()
    {
        for (int i = 1; i <= 999; i++)
            if (i % 3 == 0 && check(i))
                cout << i << endl;
        return 0;
    }
    
    • 1
      @ 2023-7-18 18:17:09
      #include <bits/stdc++.h>
      using namespace std;
      bool ans(int n){
          while (n){
              if (n % 10 == 5) return true;
              n /= 10;
          }
          return false;
      }
      int main(){
          for (int i = 1; i <= 999; i++) if (ans(i) && i % 3 == 0) cout << i << "\n";
      }
      
      • 1
        @ 2022-10-3 18:21:30

        `

        #include <iostream>//hetao3097453
        using namespace std;
        int main()
        {
            for(int i = 1; i <= 999;i++)
            {
                if(i % 3 == 0)
                {
                    if(i % 10 == 5 || i / 10 % 10 == 5 || i / 100 == 5)
                    {
                        cout << i << endl;
                    }
                }
            }
            return 0;
        }
        
        • 0
          @ 2024-1-30 16:03:04
          #include <iostream>
          using namespace std;
          bool check(int n)
          {
              while(n)
              {
                  if (n % 10 == 5)
                      return true;
                  n /= 10;
              }
              return false;
          }
          int main()
          {
              for (int i = 1; i <= 999; i++)
                  if (i % 3 == 0 && check(i))
                      cout << i << endl;
              return 0;
          }
          
          • 0
            @ 2024-1-18 18:55:22

            题解,但不能复制 image

            • 0
              @ 2023-4-22 14:34:08
              #include <bits/stdc++.h> 
              using namespace std;
              int main()
              {
                  for (int i = 1; i <= 999; i++)
                  {
                      int n = i;
                      if (n % 3 == 0)
                      {
                          while(n)
                          {
                              if (n % 10 == 5)
                              {
                                  cout << i << endl;
                                  break;
                              }
                              n /= 10;
                          }
                      }
                  }
                  return 0;
              }
              
              • -1
                @ 2022-9-3 10:50:57
                for (int i=3;i<=999;i+=3)
                {
                    if (i%10==5 || i/10%10==5 || i/100==5)
                    {
                        cout<<i<<'\n';
                    }
                }
                
                • 1

                信息

                ID
                60
                时间
                1000ms
                内存
                16MiB
                难度
                3
                标签
                递交数
                294
                已通过
                147
                上传者