fork download
  1. #include <iostream>
  2. #include<set>
  3. #include<algorithm>
  4. #include<vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(false);
  10. int n,k;
  11. cin>>n>>k;
  12. vector<int> a(n);
  13. for(int i =0; i<n; ++i) cin>>a[i];
  14. sort(a.begin(),a.end());
  15. set<int> used;
  16. for(int i = 0; i<n; ++i)
  17. if(a[i]%k!=0 || !used.count(a[i]/k))
  18. used.insert(a[i]);
  19. cout << used.size();
  20.  
  21. }
  22.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty