4 solutions

  • 1
    @ 2026-5-30 11:16:07
    #include<bits/stdc++.h>
    using namespace std;
    bool a(int k)
    {
    	if(k<2)
    	{
    		return false;
    	}
    	for(int i=2;i<=k/i;i++) //枚举小因子 
    	{
    		if(k%i==0) //存在小因子 
    		{
    			return false;
    		}
    	}
    	return true;
    }
    int main()
    {
    	int n;
    	cin>>n;
    	int cnt=0; 
    	for(int i=1;i+2<=n;i++)
    	{
    		if(a(i)&&a(i+2))
    		{
    			cout<<i<<" "<<i+2<<endl;	
    			cnt++;
    		}
    	}
    	if(cnt==0)
    	{
    		cout<<"empty";
    	}
    	return 0;
    }

    Information

    ID
    931
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    56
    Accepted
    23
    Uploaded By