1 条题解

  • 0
    @ 2025-8-31 12:32:07
    #include <bits/stdc++.h>
    using namespace std;
    bool isPrime(int a)
    {
        if(a<2)
        {
            return false;
        }
        if(a==2)
        {
            return true;
        }
        for(int i=2;i<=sqrt(a);i++)
        {
            if(a%i==0)
            {
                return false;
            }
        }
        return true;
    }
    void number(int b)
    {
        bool found = false;
        for(int i=1;i<=b-2;i++)
        {
            if(isPrime(i) && isPrime(i+2))
            {
                cout<<i<<" "<<i+2<<endl;
                found = true;
            }
        }
        if(!found)
        {
            cout<<"empty";
        }
    }
    int main()
    {
        int n;
        cin>>n;
        number(n);
    }
    

    信息

    ID
    733
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    5
    已通过
    2
    上传者