1 条题解

  • 2
    @ 2023-11-11 21:54:06

    第一个做对的竞赛题(我实在是太有实力了)

    #include <bits/stdc++.h> 
    using namespace std;
    string shift(int x)
    {
        stringstream s;
        s << x;
        return s.str();
    }
    bool zichuan(string s)
    {
        for(int i = 0; i < s.length() - 1; i++)
        {
            if((s[i] == '4' and s[i + 1] == '4') or (s[i] == '7' and s[i + 1] == '7'))
            {
                return true;
            }
        }
        return false;
    }
    int main()
    {
        long long n, num = 0;
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            if((i % 4 == 0) or (i % 7 == 0) or (zichuan(shift(i))))
            {
                num++;
                continue;
            }
        }
        cout << num;
        return 0;
    }
    
    • 1

    信息

    ID
    551
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    32
    已通过
    16
    上传者