Educational Codeforces Round 84 E 组合,数学

给定n的大小问从000…(n个)到999…(n个)数当中
连续相等的数的个数分别有几个
例如 00027734000 中有一个大小的块为3个 两个大小的为1个 三个都2个

在这里插入图片描述

#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mod = 998244353;
const int maxn = 2e5+7;
ll quickpow(ll a,ll b)
{
    
    
    ll res = 1;
    a = a%mod;
    while(b>0)
    {
    
    
        if(b & 1)
            res = (a*res)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
ll ans[maxn];

int main()
{
    
    
    ll n;
    scanf("%lld",&n);
    ans[n] = 10,ans[n-1] = 180;
    for(int i = 1;i <= n-2;i ++)
    {
    
    
        ll tmp = (ll)(n-i);
        ans[i] = ((tmp-1)*810*quickpow((ll)10,tmp-2)%mod)%mod;// 这是不贴边的情况
        ans[i] = (ans[i]%mod + (180*quickpow((ll)10,tmp-1)%mod))%mod;
        ans[i]%=mod;
    }
    for(int i = 1;i <= n;i ++)
        printf(i == n?"%lld\n":"%lld ",ans[i]);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_45672411/article/details/105230209
今日推荐