Pagini recente » Cod sursa (job #2916936) | Cod sursa (job #1922519) | Cod sursa (job #2645247) | Cod sursa (job #744278) | Cod sursa (job #1513886)
#include <fstream>
#include <string>
using namespace std;
bool v[26][26];
int d[1001][26];
main()
{
ofstream out("nrcuv.out");
ifstream in("nrcuv.in");
int n, m, total;
in >> n >> m >> ws;
for(int i = 1; i <= m; i++)
{
char a, b;
in >> a >> ws >> b >> ws;
v[a-'a'][b-'a'] = v[b-'a'][a-'a'] = true;
}
for(int i = 0; i <= 25; i++)
{
d[1][i] = 1;
}
for(int i = 2; i <= n; i++)
{
for(int j = 0; j <= 25; j++)
{
for(int k = 0; k <= 25; k++)
{
if(!v[j][k])
{
d[i][j] = (d[i][j] + d[i-1][k])%104659;
}
}
}
}
total = 0;
for(int i = 0; i<=25; i++)
{
total = (total + d[n][i])%104629;
}
out << total;
}