69 lines
1.0 KiB
C++
69 lines
1.0 KiB
C++
#include <iostream>
|
|
#include<cstdio>
|
|
#include<algorithm>
|
|
#include <cmath>
|
|
#include<string>
|
|
using namespace std;
|
|
const int mod=998244353,N=21;
|
|
string s[N];
|
|
bool b[N][30];
|
|
int sum[N];
|
|
long long ans=0;
|
|
long long qpow(long long n,int l )
|
|
{
|
|
long long now=n,res=1;
|
|
while(l>0)
|
|
{
|
|
if(l&1==1)
|
|
{
|
|
res*=now;
|
|
res%=mod;
|
|
}
|
|
l=l>>1;
|
|
now*=now;
|
|
now%=mod;
|
|
}
|
|
return res;
|
|
}
|
|
int main()
|
|
{
|
|
int n,l;
|
|
scanf("%d%d",&n,&l);
|
|
for(int i=1; i<=n; i++)
|
|
{
|
|
cin>>s[i];
|
|
int len=s[i].size() ;
|
|
for(int j=0; j<len; j++)
|
|
{
|
|
//˳Ðò·´ÁË
|
|
if(b[i][s[i][j]-'a']==0)
|
|
{
|
|
sum[i]++;
|
|
}
|
|
b[i][s[i][j]-'a']=1;
|
|
}
|
|
printf("%d:\n%d+%d(%d)=",i,ans,qpow(sum[i],l),sum[i]);
|
|
ans+=qpow(sum[i],l);
|
|
ans%=mod;
|
|
printf("%d\n",ans);
|
|
for(int k=1; k<i; k++)
|
|
{
|
|
sum[i]=0;
|
|
for(int j=0; j<len; j++)
|
|
{
|
|
if(b[k][s[i][j]-'a']==1)
|
|
{
|
|
// b[k][s[i][j]-'a']=0;
|
|
sum[i]++;
|
|
}
|
|
}
|
|
printf("%d-%d(%d)=",ans,qpow(sum[i],l),sum[i]);
|
|
ans-=qpow(sum[i],l);
|
|
ans=(ans+mod)%mod;
|
|
printf("%d\n",ans);
|
|
}
|
|
}
|
|
printf("%lld",ans);
|
|
return 0;
|
|
}
|