Pagini recente » Cod sursa (job #1778453) | Cod sursa (job #1509312) | Cod sursa (job #3183517) | Cod sursa (job #3180160) | Cod sursa (job #603319)
Cod sursa(job #603319)
#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+=2;
ind[ch1-96][ch2-96]=true;
ind[ch2-96][ch1-96]=true;
}
else {
++nr;
ind[ch1-96][ch2-96]=true;
}
--m;
}
fout<<p-nr;
fin.close(); fout.close();
return 0;
}