QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579233 | #9309. Graph | huanmeng | WA | 0ms | 3600kb | C++14 | 838b | 2024-09-21 10:49:52 | 2024-09-21 10:49:52 |
Judging History
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'