QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579233#9309. GraphhuanmengWA 0ms3600kbC++14838b2024-09-21 10:49:522024-09-21 10:49:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-21 10:49:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-09-21 10:49:52]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std;

// 快速计算欧拉函数 φ(n)
long long euler_phi(long long n) {
    long long result = n;
    for (long long p = 2; p * p <= n; p++) {
        if (n % p == 0) {
            while (n % p == 0) n /= p;
            result -= result / p;
        }
    }
    if (n > 1) result -= result / n;
    return result;
}

// 计算完美图的数量
long long count_perfect_graphs(long long n, long long mod) {
    long long result = 1;  // 初始值为 1,因为 n=2 时有一个完美图
    for (long long i = 2; i <= n; i++) {
        result = (result * euler_phi(i)) % mod;
    }
    return result;
}

int main() {
    long long n;
    const long long mod = 998244353;
    cin >> n;
    cout << count_perfect_graphs(n, mod) << endl;
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

4

output:

4

result:

wrong answer expected '8', found '4'