Educational Codeforces Round 84 (Rated for Div. 2)E(组合数学)

 1 #define HAVE_STRUCT_TIMESPEC
 2 #include<bits/stdc++.h>
 3 using namespace std;
 4 const int mod = 998244353;
 5 long long p[200007];
 6 int main(){
 7     ios::sync_with_stdio(false);
 8     cin.tie(NULL);
 9     cout.tie(NULL);
10     int n;
11     cin>>n;
12     p[0]=1;
13     for(int i=1;i<=n;++i)
14         p[i]=p[i-1]*10%mod;
15     for(int i=1;i<n;++i){
16         long long ans=2*10*9*p[n-i-1]%mod;//连续i个数字出现在数字串的两端,以一个不同的数字分隔开,剩下随便选
17         if(i<=n-2)//可以出现在数字串的中间
18             ans=(ans+10*(n-i-1)*9*9*p[n-i-2])%mod;//n-i+1种位置,每种位置10种数字,两端以不同的数字分隔开,各有九种,剩下的数字有10^(n-i-2)种情况随便选
19         cout<<ans<<" ";
20     }
21     cout<<10;//n个数字全部相同
22     return 0;
23 }

猜你喜欢

转载自www.cnblogs.com/ldudxy/p/12594641.html