Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
24215 | yihang | 【PAT】性感素数 | C++ | 解答错误 | 0 MS | 252 KB | 349 | 2023-07-21 20:26:00 |
#include"bits/stdc++.h" using namespace std; int s(int x){ for(int i=2;i*i<=x;i++){ if(x%i==0)return false;} return true;} int main(){ long long n; cin>>n; if(s(n)){ cout<<"Yes"<<endl; if(s(n-6)){ cout<<n-6;} else if(s(n+6)){ cout<<n+6;}} else{ cout<<"No"<<endl; while(n++){ if(s(n)){ cout<<n; return 0;} }} }