Problem Description
One day, Y_UME got an integer
).
In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Note that empty subsequence is also a subsequence of original sequence.
Refer to https://en.wikipedia.org/wiki/Subsequence for better understanding.
In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Note that empty subsequence is also a subsequence of original sequence.
Refer to https://en.wikipedia.org/wiki/Subsequence for better understanding.
Input
There are multiple test cases.
Each case starts with a line containing one integer 4.
Each case starts with a line containing one integer 4.
Output
For each test case, output one line containing an integer denoting the answer.
Sample Input
1
2
3
Sample Output
0
332748118
554580197
Source
Recommend
推导公式为(n*n-1 / 9)%998244353
套上公式求下逆元就好了
代码:
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<stack> #include<set> #include<vector> #include<map> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; ll ksm(ll x,ll y) { ll ans=1; while(y) { if(y&1) { ans=(ans*x)%998244353; } y>>=1; x=(x*x)%998244353; } return ans; } int main() { ll n; while(~scanf("%lld",&n)) { ll ans=((n*n-1)*ksm(9,998244351))%998244353; printf("%lld\n",ans); } return 0; }