Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
58514 | littletwleve | 判断一个数是否为质数 | C++ | Accepted | 0 MS | 256 KB | 283 | 2024-12-12 15:10:53 |
#include<bits/stdc++.h> using namespace std; bool p(int n){ bool f=1; if(n==2) return f; else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ f=0; continue; } } } return f; } int main(){ int n; cin>>n; if(p(n)) cout<<"yes"; else cout<<"no"; }