Pagini recente » Cod sursa (job #2511812) | Cod sursa (job #851510) | Cod sursa (job #2526839) | Cod sursa (job #2964344) | Cod sursa (job #604782)
Cod sursa(job #604782)
#include<fstream>
#define modulo 104659
using namespace std;
bool ind[27][27];
int n,m,nr,p,vector[27];
char ch1,ch2,aux;
int power26(int a){
int p=26;
for(int i=2;i<=a;++i)
p=(p*26)%modulo;
return p;
}
int main(void){
ifstream fin("nrcuv.in");
ofstream fout("nrcuv.out");
fin>>n>>m;
p=power26(n); nr=0;
while (m){
fin>>ch1>>ch2;
if(!ind[ch1-96][ch2-96])
if(ch1!=ch2){
nr=(nr+2)%modulo;
ind[ch1-96][ch2-96]=true;
ind[ch2-96][ch1-96]=true;
}
else{
nr=(nr+1)%modulo;
ind[ch1-96][ch2-96]=true;
}
--m;
}
fout<<(p-nr)%modulo;
fin.close(); fout.close();
return 0;
}