QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568917 | #9309. Graph | yylx | WA | 0ms | 3644kb | C++14 | 685b | 2024-09-16 19:14:20 | 2024-09-16 19:14:21 |
Judging History
answer
#include <iostream>
using namespace std;
const long long MOD = 998244353;
// Function to compute (base^exp) % mod
long long mod_pow(long long base, long long exp, long long mod) {
long long result = 1;
while (exp > 0) {
if (exp % 2 == 1) {
result = (result * base) % mod;
}
base = (base * base) % mod;
exp /= 2;
}
return result;
}
int main() {
long long n;
cin >> n;
// The number of "perfect" graphs with n vertices is 2^(n-1)
// We need to calculate 2^(n-1) % 998244353
long long result = mod_pow(2, n - 1, MOD);
cout << result << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3644kb
input:
2
output:
2
result:
wrong answer expected '1', found '2'