Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream f("vraji.in");
- ofstream g("vraji.out");
- int p,N,Pvoc,Pcons,NrVS,pMax=-2000000000,nrMax,FLit[30];
- char VrPmax[105];
- int main()
- {
- int i,j,Pvc,nrv,nrc,nrd,Lvc,NrLitVecineIdent,aux,auxp;
- bool vrajaspeciala;
- char c,VrajaCurenta[105];
- f>>p;
- f>>N>>Pvoc>>Pcons;
- f.get();
- for(i=1;i<=N;++i)
- {
- f.get(VrajaCurenta,100,'\n');
- f.get();
- Lvc=strlen(VrajaCurenta);
- Pvc=1;
- nrv=nrc=nrd=0;
- NrLitVecineIdent=1;
- c=0;
- vrajaspeciala=false;
- for(j=0;j<Lvc;++j)
- {
- if(c==VrajaCurenta[j])
- ++NrLitVecineIdent,vrajaspeciala=true;
- else
- if(NrLitVecineIdent>1)
- {
- if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
- auxp=Pvoc;
- else
- auxp=Pcons;
- aux=auxp;
- while(NrLitVecineIdent>1)
- aux*=auxp,--NrLitVecineIdent;
- Pvc+=aux;
- }
- c=VrajaCurenta[j];
- ++FLit[c-'a'];
- if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
- ++nrv;
- else
- ++nrc;
- }
- if(NrLitVecineIdent>1)
- {
- if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
- auxp=Pvoc;
- else
- auxp=Pcons;
- aux=auxp;
- while(NrLitVecineIdent>1)
- aux*=auxp,--NrLitVecineIdent;
- Pvc+=aux;
- }
- for(j=0;j<26;++j)
- {
- if(FLit[j]>0)
- ++nrd;
- FLit[j]=0;
- }
- Pvc+=(int)((nrv*Pvoc+nrc*Pcons)/nrd);
- NrVS+=vrajaspeciala;
- if(Pvc>pMax)
- pMax=Pvc,nrMax=1,strcpy(VrPmax,VrajaCurenta);
- else
- if(Pvc==pMax)
- ++nrMax;
- }
- f.close();
- if(p==1)
- g<<NrVS<<'\n';
- else
- g<<nrMax<<' '<<VrPmax<<'\n';
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement