Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream in("cifre8.in");
  6. ofstream out("cifre8.out");
  7. vector<int>w;
  8. int cmmdc(int a, int b) {
  9.     if (b == 0)
  10.        return a;
  11.     else
  12.        return cmmdc(b, a%b);
  13.  
  14. }
  15.  
  16. inline bool prim ( int N )
  17. {
  18.   if ( N==0 || N==1 ) return false;
  19.  
  20.   for ( int i=2 ; i*i<=N ; ++i )
  21.     if ( N%i==0 ) return false;
  22.  
  23.   return true;
  24.  
  25. }
  26. int n,c;
  27. int cerinta1=0;
  28. int ap[10];
  29. int last[10];
  30. vector<int>v;
  31. int main()
  32.  
  33. { cin>>n>>c;
  34.           for(int i =1; i<=n ;++i)
  35.           {
  36.               int x;
  37.               cin >> x ;
  38.                  if(prim(x))cerinta1+=x;
  39.                  if(x%2==1)
  40.                     last[x%10]++;
  41.                  while(x)
  42.                  {
  43.                      ap[x%10]++;
  44.                      x/=10;
  45.                  }
  46.           }
  47.           cout<<cerinta1<<"\n"<<ap[c]<<"\n";
  48.           int sumee=0;
  49.           for(int i =1; i<=9 ; ++i)
  50.             if(last[i])w.push_back(last[i]);
  51.          int k=cmmdc(w[0],w[1]);
  52.          w[0]+=w[1];
  53.          sumee+=w[0];
  54.             for(size_t y=2 ; y < w.size(); ++y)
  55.             {
  56.                 //cout<<w[y]<<" ";
  57.                 k=cmmdc(k,w[y]);
  58.                 sumee+=w[y];
  59.             }
  60.             if(sumee%k==0)
  61.         cout<<sumee/k;
  62.         else cout<<sumee;
  63.  
  64.  return 0;
  65.  
  66.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement