Pagini recente » Cod sursa (job #1780215) | Cod sursa (job #1873583) | Cod sursa (job #482112) | Cod sursa (job #2203772) | Cod sursa (job #889462)
Cod sursa(job #889462)
#include <iostream>
#include <fstream>
#define MOD 104659
using namespace std;
ifstream in("nrcuv.in");
ofstream out("nrcuv.out");
int n,m,p[30][30],v[1010][30],i,j,k,s;
char a,b;
int main()
{
in>>n>>m;
for(i=1;i<=m;i++)
{
in>>a>>b;
v[a-97][b-97]=1;
v[b-97][a-97]=1;
}
for(i=0;i<26;i++)
p[1][i]=1;
for(i=2;i<=n;++i)
for(j=0;j<26;j++)
for(k=0;k<26;k++)
if(!v[j][k])
p[i][j]=(p[i][j]+p[i-1][k])%MOD;
for(i=0;i<26;i++)
s=(s+p[n][i])%MOD;
out<<s<<'\n';
return 0;
}