79 lines
1.2 KiB
C++
79 lines
1.2 KiB
C++
#include <iostream>
|
|
#include<cstdio>
|
|
#include<algorithm>
|
|
#include <cmath>
|
|
#include<string>
|
|
#include<cstring>
|
|
using namespace std;
|
|
const int mod=998244353,N=21;
|
|
string s[N],t[N];
|
|
bool b[N][30];
|
|
int sum[N];
|
|
long long ans=0;
|
|
bool d[N][30];
|
|
int n,l;
|
|
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;
|
|
}
|
|
void youa(int i,bool *b1[],string *s1)
|
|
{
|
|
int len=s1.size() ;
|
|
for(int j=0; j<len; j++)
|
|
{
|
|
//˳Ðò·´ÁË
|
|
if(b1[s1[j]-'a']==0)
|
|
{
|
|
sum[i]++;
|
|
}
|
|
b1[s1[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);
|
|
}
|
|
int main()
|
|
{
|
|
scanf("%d%d",&n,&l);
|
|
for(int i=1; i<=n; i++)
|
|
{
|
|
cin>>s[i];
|
|
youa(i,&b[i],&s[i]);
|
|
int cnt=0;
|
|
int len=s[i].size() ;
|
|
memset(t,0,sizeof(string)*(n+1));
|
|
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)
|
|
{
|
|
sum[i]++;
|
|
t[k]+=s[i][j];
|
|
}
|
|
}
|
|
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;
|
|
}
|