Advertisement
Guest User

Untitled

a guest
Apr 16th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<fstream>
  2. #include<deque>
  3. #include<algorithm>
  4. using namespace std;
  5. deque <int> A;
  6. int main()
  7. {
  8. ifstream in("input.txt");
  9. ofstream out("output.txt");
  10. int n, k, tmp;
  11. in>>n>>k;
  12. for(int i=0;i<n;i++)
  13. {
  14. in>>tmp;
  15. A.push_back(tmp);
  16. }
  17. sort(A.begin(), A.end());
  18. int soluzioni=0;
  19. while(A.size()>1)
  20. {
  21. if(A.front()*A.back()>k)
  22. A.pop_back();
  23. else if(A.front()*A.back()==k)
  24. {
  25. soluzioni++;
  26. A.pop_front();
  27. }
  28. else A.pop_front();
  29. }
  30. out<<soluzioni;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement