QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#149749#3531. Prime or numberxiaopacaiWA 1ms3660kbC++14516b2023-08-25 14:01:112023-08-25 14:01:12

Judging History

This is the latest submission verdict.

  • [2023-08-25 14:01:12]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3660kb
  • [2023-08-25 14:01:11]
  • Submitted

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

詳細信息

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