Advertisement
a53

vraji

a53
Aug 15th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3. using namespace std;
  4. ifstream f("vraji.in");
  5. ofstream g("vraji.out");
  6. int p,N,Pvoc,Pcons,NrVS,pMax=-2000000000,nrMax,FLit[30];
  7. char VrPmax[105];
  8.  
  9. int main()
  10. {
  11. int i,j,Pvc,nrv,nrc,nrd,Lvc,NrLitVecineIdent,aux,auxp;
  12. bool vrajaspeciala;
  13. char c,VrajaCurenta[105];
  14. f>>p;
  15. f>>N>>Pvoc>>Pcons;
  16. f.get();
  17. for(i=1;i<=N;++i)
  18. {
  19. f.get(VrajaCurenta,100,'\n');
  20. f.get();
  21. Lvc=strlen(VrajaCurenta);
  22. Pvc=1;
  23. nrv=nrc=nrd=0;
  24. NrLitVecineIdent=1;
  25. c=0;
  26. vrajaspeciala=false;
  27. for(j=0;j<Lvc;++j)
  28. {
  29. if(c==VrajaCurenta[j])
  30. ++NrLitVecineIdent,vrajaspeciala=true;
  31. else
  32. if(NrLitVecineIdent>1)
  33. {
  34. if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
  35. auxp=Pvoc;
  36. else
  37. auxp=Pcons;
  38. aux=auxp;
  39. while(NrLitVecineIdent>1)
  40. aux*=auxp,--NrLitVecineIdent;
  41. Pvc+=aux;
  42. }
  43. c=VrajaCurenta[j];
  44. ++FLit[c-'a'];
  45. if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
  46. ++nrv;
  47. else
  48. ++nrc;
  49. }
  50. if(NrLitVecineIdent>1)
  51. {
  52. if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='q'||c=='w'||c=='y')
  53. auxp=Pvoc;
  54. else
  55. auxp=Pcons;
  56. aux=auxp;
  57. while(NrLitVecineIdent>1)
  58. aux*=auxp,--NrLitVecineIdent;
  59. Pvc+=aux;
  60. }
  61. for(j=0;j<26;++j)
  62. {
  63. if(FLit[j]>0)
  64. ++nrd;
  65. FLit[j]=0;
  66. }
  67. Pvc+=(int)((nrv*Pvoc+nrc*Pcons)/nrd);
  68. NrVS+=vrajaspeciala;
  69. if(Pvc>pMax)
  70. pMax=Pvc,nrMax=1,strcpy(VrPmax,VrajaCurenta);
  71. else
  72. if(Pvc==pMax)
  73. ++nrMax;
  74. }
  75. f.close();
  76. if(p==1)
  77. g<<NrVS<<'\n';
  78. else
  79. g<<nrMax<<' '<<VrPmax<<'\n';
  80. g.close();
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement