Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
24154 我要进前十(黄泽远) 【PAT】性感素数 C++ 解答错误 0 MS 248 KB 454 2023-07-21 14:59:03

Tests(1/20):


#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; }


测评信息: