fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <ctime>
  5. #include <string.h>
  6. using namespace std;
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. vector<int> number(n);
  12. for(int i = 0; i<n; i++){
  13. cin >> number[i];
  14. }
  15. set<int> fib;
  16. int a=1;
  17. int b=1;
  18. while(b<=100){
  19. fib.insert(b);
  20. int next = a+b;
  21. a = b;
  22. b = next;
  23. }
  24. set<int>::iterator iter;
  25. for(vector<int>::iterator it = number.begin(); it != number.end();){
  26. if(fib.find(*it) != fib.end()){
  27. it = number.erase(it);
  28. }
  29. else{
  30. it++;
  31. }
  32.  
  33. }
  34. for(vector<int>::iterator it = number.begin(); it != number.end(); it++){
  35. cout << *it << " ";
  36. }
  37. cout <<endl;
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
5
3 5 374 8 12
stdout
374 12