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.
 

 

Input
There are multiple test cases.

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
liuyiding   |   We have carefully selected several similar problems for you:  6602 6601 6600 6599 6598 
 
推导公式为(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;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
相关资源
相似解决方案