Calculation of Contribution reverse order, i.e., in how many steps the desired number of n to be deleted which would delete two numbers, provided f (n) represents a desired case, there equation $ f [n] = 3/4 + (\ sum_ {i = 2} ^ {n} f [i] \ cdot c (n-2, i-2)) / 2 ^ n $, hand calculations (play list) to give f [i] = 4 / 3 (substituting established), so $ ans = \ sum_ {i = 1} ^ {n} (i-1) i / 3 = 1/3 (n (n + 1) (2n + 1) / 6-n ( n + 1) / 2) = (n-1) (n + 1) / 9 $
1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 int main(){ 5 while (scanf("%d",&n)!=EOF)printf("%d\n",443664157LL*(n-1)*(n+1)%998244353); 6 }