fork download
  1. #include <algorithm>
  2. #include <iterator>
  3. #include <iostream>
  4. #include <vector>
  5. #include <set>
  6.  
  7. int main()
  8. {
  9. std::set<int> s, s4;
  10.  
  11. int n;
  12.  
  13. while (std::cin >> n) {
  14. s .insert(n );
  15. s4.insert(n * 4);
  16. }
  17.  
  18. std::vector<int> r;
  19.  
  20. std::set_intersection(s .begin(), s .end(),
  21. s4.begin(), s4.end(), std::back_inserter(r));
  22.  
  23. for (auto n : r) {
  24. std::cout << n / 2 << " ("
  25. << n / 4 << ", "
  26. << n << ") " << std::endl;
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3480KB
stdin
1
2
3
4
5

11
12
13
14
15
16
17
18
19
20

stop
stdout
2 (1, 4) 
6 (3, 12) 
8 (4, 16) 
10 (5, 20)