Pagini recente » Cod sursa (job #1116024) | Cod sursa (job #786376) | Cod sursa (job #757063) | Cod sursa (job #3259586) | Cod sursa (job #1526443)
#include<cstdio>
using namespace std;
int v[26][26],d[26][1005],n,m,s;
char a,b;
int main(){
freopen("nrcuv.on", "r", stdin);
freopen("nrcuv.out", "w", stdout);
scanf("%d %d", &n, &m);
for(int i=1;i<=m;++i){
scanf("%d %d", &a, &b);
v[a-'a'][b-'a']=1;
v[b-'a'][a-'a']=1;
}
for(int i=0;i<26;++i){
d[i][1]=1;
}
for(int i=2;i<=n;++i){
for(int j=0;j<=25;++j){
for(int ofya=0;ofya<=25;++ofya){
if(v[ofya][j]==0){
d[j][i]+=d[ofya][i-1];
d[j][i]%=104659;
}
}
}
}
for(int i=0;i<26;++i){
s+=d[i][n];
s%=104659;
}
printf("%d", s);
}