Codeforces(E. Count The Blocks)数学

Original title link: https: //codeforces.com/contest/1327/problem/E

Release from the equation will be the
first 10, second 180, the third is 2610 ·········
find n-* 10 = n- n- - (A [. 1] * n-+ a [2] * (n- 1) + ······ + a [n-1] * 2)

Code:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll a[200005],mod=998244353;
 
ll apow(ll a,ll b)
{
    ll s=1;
    while(b)
    {
        if(b&1)
        {s=s*a%mod;}
        a=a*a%mod;
        b>>=1;
    }
    return s;
}
int main()
{
    ll n;
    cin>>n;
    if(n==1)
    {cout<<"10"<<endl;return 0;}
    a[1]=10;
    ll val=20,op=20,basic=10;
    for(int i=2;i<=n;i++)
    {
        a[i]=((i*apow(10,i))%mod-val+mod)%mod;
        basic=(basic+a[i])%mod;
        val=(val+basic+a[i])%mod;
    }
    for(int i=n;i>=1;i--)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}
Published 36 original articles · won praise 4 · Views 1375

Guess you like

Origin blog.csdn.net/qq_43781431/article/details/105115853