STANAANDREY

razb

Jan 4th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include<fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream cin("razboi.in");
  6. ofstream cout("razboi.out");
  7.  
  8. const int N=100000;
  9. int n, i,j, low, nr,prime[N],k=0,s;
  10.  
  11. void cas1()
  12. {
  13.     int cnt1=0,cnt2=0,p;
  14.     for(i=1;i<=n;i++)
  15.     {
  16.         cin>>nr;
  17.         p=nr%10;
  18.         if(p%2==0)
  19.             cnt1++;
  20.         else
  21.             cnt2++;
  22.     }
  23.     cout<<cnt1<<" "<<cnt2;
  24. }
  25.  
  26. int  divid(int N) {
  27.     int sum = 1, nrd = 1;
  28.  
  29.     for(int d = 2; N > 1; ++d) {
  30.         if(1LL*d*d > N) break;
  31.         if(N % d) continue;
  32.         int nrc = 0;
  33.         int act_prod = 1, act_sum = 1;
  34.         while(N % d == 0) {
  35.             act_prod *= d;
  36.             act_sum += act_prod;
  37.             N /= d;
  38.             ++nrc;
  39.         }
  40.         sum *= act_sum;
  41.  
  42.         nrd *= (nrc+1);
  43.     }
  44.     if(N != 1) {
  45.         nrd *= 2;
  46.         sum = (1LL*sum*(N+1));
  47.     }      
  48.     return sum;
  49. }
  50. void cas2()
  51. {
  52.     int cnt1=0,cnt2=0;
  53.     for(i=1;i<=n;i++)
  54.     {
  55.         cin>>nr;
  56.         s=divid(nr);
  57.         if(s%2==0)
  58.             cnt1++;
  59.         else
  60.             cnt2++;
  61.     }
  62.     cout<<cnt1<<" "<<cnt2;
  63. }
  64.  
  65. int main()
  66. {
  67.     cin>>n>>low;
  68.     if(low==1)
  69.         cas1();
  70.     else
  71.         cas2();
  72. }
Add Comment
Please, Sign In to add comment