传送门
题解:
和上一道题差不读多,都是连续块状的类似问题,这道题需要考虑边界,当我们块在最开始或者最后面的时候,和这个块相邻的位置只有一个,这个位置不能和块内数字一样所以他只有9种选法,而块内和块外一共有10种选法,因为这种块只有2种情况所以再乘以2。再看看其他位置,在其他位置的时候块旁边有两个位置,所以是9*9再看看这种块存在多少个,一共存在(n-(i+2)+1)块。所以代码如下。
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
typedef long long ll;
const int MOD=998244353;
ll ans[maxn];
ll qpow(ll x, int y) {
ll res = x%MOD, ans = 1;
while(y) {
if (y&1) ans = ans*res%MOD;
res = res*res%MOD;
y >>= 1;
}
return ans%MOD;
}
int main(void) {
ll n;
scanf("%lld", &n);
ans[n] = 10, ans[n-1] = 180;
for (ll i = 1; i<=n-2; ++i)
ans[i] = (ans[i] + 10LL*9*2*qpow(10, n-i-1)%MOD + 10LL*9*9*(n-i-1)%MOD*qpow(10, n-i-2))%MOD;
for (int i = 1; i<=n; ++i)
printf(i==n ? "%lld\n" : "%lld ", ans[i]);
return 0;
}