Advertisement
rahat62

A. Paint the Numbers

Sep 15th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int ar[200],arr[200],t,cnt=0;
  6.  
  7.     cin>>t;
  8.  
  9.  
  10.     for(int i=0 ; i<t ; i++)
  11.     {
  12.         cin>>ar[i];
  13.     }
  14.      for(int i=0 ; i<t ; i++)
  15.     {
  16.         arr[i]=ar[i];
  17.     }
  18.  
  19.  
  20.     for(int i=0 ; i<t ; i++)
  21.     {
  22.         for(int j=0;j<t;j++)
  23.         {
  24.             if(arr[j]%ar[i]==0)
  25.             {
  26.                 arr[j]=ar[i];
  27.                 cnt++;
  28.             }
  29.         }
  30.     }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.     set < int > amarSet;
  37.     int in;
  38.     for (int i=0; i<t; i++) {
  39.         in = arr[i];
  40.         amarSet.insert(in);
  41.     }
  42.  
  43.     set < int > :: iterator it;
  44.  
  45.     cout << amarSet.size() << endl;
  46.  
  47.  
  48.  
  49.  
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement