Advertisement
a53

Becuri1

a53
Apr 12th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #include <fstream>
  2. #define N 100
  3. using namespace std;
  4. int n,b[N];
  5. long long v[N],p[N];
  6. ifstream f("becuri1.in");
  7. ofstream g("becuri1.out");
  8.  
  9. void citire(long long v[],int n)
  10. {
  11. for(int i=0;i<n;++i)
  12. f>>v[i];
  13. }
  14.  
  15. void numarare(long long p[])
  16. {
  17. int i,cp;
  18. for(i=0;i<n;++i)
  19. {
  20. p[i]=1;
  21. cp=v[i];
  22. if(cp==0)
  23. p[i]=1;
  24. else
  25. {
  26. while(cp)
  27. p[i]*=10,cp/=10;
  28. p[i]=p[i]/10;
  29. }
  30. }
  31. }
  32.  
  33. void cerinta_1(long long v[],int n)
  34. {
  35. int ca=0;
  36. numarare(p);
  37. for(int i=0;i<n;++i)
  38. if(v[i]/p[i]==2||v[i]/p[i]==3||v[i]/p[i]==5||v[i]/p[i]==7)
  39. ++ca;
  40. g<<ca;
  41. }
  42.  
  43. void cerinta_2(long long v[],int n)
  44. {
  45. int c=0,maxbec,maxp=0;
  46. numarare(p);
  47. for(int i=0;i<n;++i)
  48. {
  49. if(p[i]>maxp)
  50. maxp=p[i];
  51. if(v[i]/p[i]==2||v[i]/p[i]==3||v[i]/p[i]==5||v[i]/p[i]==7)
  52. ++c;
  53. }
  54. maxbec=c;
  55. while(maxp!=1)
  56. {
  57. c=0;
  58. for(int i=0;i<n;++i)
  59. {
  60. v[i]=v[i]%p[i]*10+v[i]/p[i];
  61. if(v[i]/p[i]==2||v[i]/p[i]==3||v[i]/p[i]==5||v[i]/p[i]==7)
  62. ++c;
  63. }
  64. if(c>maxbec)
  65. maxbec=c;
  66. maxp/=10;
  67. }
  68. g<<maxbec;
  69. }
  70.  
  71. void cerinta_3(long long v[],int n)
  72. {
  73. int maxp=0;
  74. numarare(p);
  75. for(int i=0;i<n;++i)
  76. {
  77. if(p[i]>maxp)
  78. maxp=p[i];
  79. if(v[i]/p[i]==2||v[i]/p[i]==3||v[i]/p[i]==5||v[i]/p[i]==7)
  80. ++b[i];
  81. }
  82. while(maxp!=1)
  83. {
  84. for(int i=0;i<n;++i)
  85. {
  86. v[i]=v[i]%p[i]*10+v[i]/p[i];
  87. if(v[i]/p[i]==2||v[i]/p[i]==3||v[i]/p[i]==5||v[i]/p[i]==7)
  88. ++b[i];
  89. }
  90. maxp/=10;
  91. }
  92. maxp=0;
  93. for(int i=0;i<n;++i)
  94. if(b[i]>maxp)
  95. maxp=b[i];
  96. if(maxp==0)
  97. g<<-1<<' ';
  98. else
  99. for(int i=0;i<n;++i)
  100. if(b[i]==maxp)
  101. g<<i+1<<' ';
  102. }
  103.  
  104. int main()
  105. {
  106. int c;
  107. f>>c>>n;
  108. citire(v,n);
  109. switch(c)
  110. {
  111. case 1: cerinta_1(v,n); break;
  112. case 2: cerinta_2(v,n); break;
  113. case 3: cerinta_3(v,n); break;
  114. }
  115. return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement