Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream in("cifre8.in");
- ofstream out("cifre8.out");
- vector<int>w;
- int cmmdc(int a, int b) {
- if (b == 0)
- return a;
- else
- return cmmdc(b, a%b);
- }
- inline bool prim ( int N )
- {
- if ( N==0 || N==1 ) return false;
- for ( int i=2 ; i*i<=N ; ++i )
- if ( N%i==0 ) return false;
- return true;
- }
- int n,c;
- int cerinta1=0;
- int ap[10];
- int last[10];
- vector<int>v;
- int main()
- { cin>>n>>c;
- for(int i =1; i<=n ;++i)
- {
- int x;
- cin >> x ;
- if(prim(x))cerinta1+=x;
- if(x%2==1)
- last[x%10]++;
- while(x)
- {
- ap[x%10]++;
- x/=10;
- }
- }
- cout<<cerinta1<<"\n"<<ap[c]<<"\n";
- int sumee=0;
- for(int i =1; i<=9 ; ++i)
- if(last[i])w.push_back(last[i]);
- int k=cmmdc(w[0],w[1]);
- w[0]+=w[1];
- sumee+=w[0];
- for(size_t y=2 ; y < w.size(); ++y)
- {
- //cout<<w[y]<<" ";
- k=cmmdc(k,w[y]);
- sumee+=w[y];
- }
- if(sumee%k==0)
- cout<<sumee/k;
- else cout<<sumee;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement