提交时间:2023-07-21 17:36:23

运行 ID: 24190

#include <bits/stdc++.h> using namespace std; bool check(int x){ if(x==1)return false; for(int i=2;i*i<=x;i++) if(x%i==0){ return false; } return true; } int main(){ int n,ans; cin>>n; if(check(n)){ if(check(n-6)&&n-6>0){ cout<<"Yes"<<endl; cout<<n-6; return 0; } if(check(n+6)){ cout<<"Yes"<<endl; cout<<n+6; return 0; } } cout<<"No"<<endl; while(n++){ if(check(n)&&check(n-6)&&n-6>0){ cout<<n; return 0; } if(check(n)&&check(n+6)){ cout<<n; return 0; } } }