Pagini recente » Cod sursa (job #2214739) | Cod sursa (job #2214732) | Cod sursa (job #1303464) | Istoria paginii runda/terente.2/clasament | Cod sursa (job #1884772)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("nrcuv.in");
ofstream g("nrcuv.out");
int b[1001][1001],n,m;
unsigned long long a[1001][27];
int main()
{
f>>n>>m;
char x,y;
for(int i=1;i<=m;i++){
f>>x>>y;
b[x-96][y-96]=1;
b[y-96][x-96]=1;
}
for(int i=1;i<=26;i++) a[1][i]=1;
for(int i=2;i<=n;i++)
for(int j=1;j<=26;j++)
for(int k=1;k<=26;k++)
if(b[j][k]==0)
a[i][j]=a[i][j]+a[i-1][k];
int c=0;
for(int i=1;i<=26;i++){
c+=a[n][i];
if(c>=104659) c/=104659;
}
g<<c;
}