提交时间:2023-07-21 14:59:03

运行 ID: 24154

#include "iostream" using namespace std; bool check(int x){ for(int i=2;i*i<=x;i++){ if(x%i==0)return false; } return true; } void xing(int x){ if(check(x+6)){ cout<<"Yes"<<'\n'; if(check(x-6)){ cout<<x-6; } else { cout<<x+6; } return; } cout<<"No"<<'\n'; while(x++){ if(check(x)&&(check(x+6)||check(x-6))){ cout<<x; return ; } } } int main(){ int n; cin>>n; xing(n); return 0; }