Mai intai trebuie sa te autentifici.
Cod sursa(job #603319)
Utilizator | Ion Ureche ion824 | Data | 15 iulie 2011 14:52:21 |
---|---|---|---|
Problema | Lista lui Andrei | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.87 kb |
#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;
}