Submission #38485641


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define MOD 998244353
using namespace std;
int mul(const int &a, const int &b)
{
    return 1LL * a * b % MOD;
}
void Inc(int &a, const int &b)
{
    ((a += b) >= MOD) && (a -= MOD);
}
void Mul(int &a, const int &b)
{
    a = 1LL * a * b % MOD;
}
void Sqr(int &a)
{
    a = 1LL * a * a % MOD;
}
int qwqmi(int x, int k = MOD - 2)
{
    int res = 1;
    while(k)
    {
        if(k & 1) Mul(res, x);
        Sqr(x), k >>= 1;
    }
    return res;
}
const int N = 1e7 + 5;
int n, ans, f[N], inv[N];
int main()
{
    scanf("%d", &n);
    inv[1] = 1;
    f[0] = 1, f[1] = 6 * n;
    for(int i = 2; i < n; ++i)
    {
        f[i] = mul(3 *(2 * n - i + 1), f[i - 1]);
        Inc(f[i], mul(4 * n - i + 2, f[i - 2]));
        inv[i] = mul(inv[MOD % i], MOD - MOD / i);
        Mul(f[i], inv[i]);
    }
    ans = mul(f[n - 1], qwqmi(n));
    printf("%d\n", ans);
    return 0;
}

Submission Info

Submission Time
Task H - Beautiful Binary Tree
User Schucking_Sattin
Language C++ (GCC 9.2.1)
Score 600
Code Size 961 Byte
Status AC
Exec Time 283 ms
Memory 81732 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   35 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_medium_00.txt, 02_medium_01.txt, 02_medium_02.txt, 02_medium_03.txt, 02_medium_04.txt, 02_medium_05.txt, 02_medium_06.txt, 02_medium_07.txt, 02_medium_08.txt, 02_medium_09.txt, 03_large_00.txt, 03_large_01.txt, 03_large_02.txt, 03_large_03.txt, 03_large_04.txt, 04_max_00.txt, 04_max_01.txt, 04_max_02.txt, 05_random_00.txt, 05_random_01.txt, 05_random_02.txt, 05_random_03.txt, 05_random_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3520 KiB
00_sample_01.txt AC 3 ms 3628 KiB
00_sample_02.txt AC 2 ms 3628 KiB
00_sample_03.txt AC 7 ms 5508 KiB
01_small_00.txt AC 3 ms 3652 KiB
01_small_01.txt AC 2 ms 3708 KiB
01_small_02.txt AC 2 ms 3628 KiB
01_small_03.txt AC 2 ms 3568 KiB
01_small_04.txt AC 2 ms 3652 KiB
01_small_05.txt AC 2 ms 3520 KiB
01_small_06.txt AC 2 ms 3640 KiB
01_small_07.txt AC 2 ms 3516 KiB
02_medium_00.txt AC 2 ms 3628 KiB
02_medium_01.txt AC 2 ms 3520 KiB
02_medium_02.txt AC 2 ms 3572 KiB
02_medium_03.txt AC 2 ms 3656 KiB
02_medium_04.txt AC 2 ms 3716 KiB
02_medium_05.txt AC 2 ms 3712 KiB
02_medium_06.txt AC 1 ms 3628 KiB
02_medium_07.txt AC 2 ms 3616 KiB
02_medium_08.txt AC 2 ms 3704 KiB
02_medium_09.txt AC 2 ms 3660 KiB
03_large_00.txt AC 220 ms 68740 KiB
03_large_01.txt AC 241 ms 75056 KiB
03_large_02.txt AC 212 ms 66084 KiB
03_large_03.txt AC 283 ms 79800 KiB
03_large_04.txt AC 160 ms 53008 KiB
04_max_00.txt AC 279 ms 81636 KiB
04_max_01.txt AC 277 ms 81732 KiB
04_max_02.txt AC 279 ms 81680 KiB
05_random_00.txt AC 79 ms 29268 KiB
05_random_01.txt AC 142 ms 48172 KiB
05_random_02.txt AC 115 ms 40956 KiB
05_random_03.txt AC 237 ms 69488 KiB
05_random_04.txt AC 45 ms 17328 KiB