QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#149749 | #3531. Prime or number | xiaopacai | WA | 1ms | 3660kb | C++14 | 516b | 2023-08-25 14:01:11 | 2023-08-25 14:01:12 |
Judging History
answer
#include <iostream>
using namespace std;
// 函数用于检查一个数是否为质数
bool isPrime(int n) {
if (n <= 1)
return false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
int main() {
long long n;
cin >> n;
// 判断n是否为质数,如果是则输出"Yes",否则输出"No"
if (isPrime(n))
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
input:
2
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
42
output:
No
result:
ok answer is NO
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3660kb
input:
16
output:
No
result:
wrong answer expected YES, found NO