QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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'