Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
24170 | hetiantian | 【PAT】性感素数 | C++ | 解答错误 | 0 MS | 248 KB | 530 | 2023-07-21 15:55:48 |
#include <bits/stdc++.h> using namespace std; bool check(int x){ for(int i=2;i*i<=x;i++) if(x%i==0){ return false; } return true; } int main(){ int n,ans; cin>>n; int m=n-6,s=n+6; if(check(n)){ if(m==5){ cout<<"Yes"<<endl; cout<<"11"; return 0; } else if(m==2||m==3){ cout<<"No"; return 0; } if(check(m)||check(s)){ cout<<"Yes"<<endl; ans=min(m,s); cout<<ans; return 0; } else{ cout<<"No"; return 0; } } else{ cout<<"No"; } }