Cod sursa(job #604781)

Utilizator ion824Ion Ureche ion824 Data 25 iulie 2011 10:59:57
Problema Lista lui Andrei Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 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=(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;
}