Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ITEMS REMAINED
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int x;
- //sequence A
- vector<int> a;
- //sequence B
- vector<int> b;
- vector<int> c;
- //reading sequence A
- while (cin >> x && x != -1)
- {
- a.push_back(x);
- }
- //reading sequence B
- while (cin >> x && x != -1)
- {
- b.push_back(x);
- }
- for (int x : b)
- {
- for (int i = 0; i < a.size(); i++)
- {
- //add a[i] to C if a[i] isn't divisible by b[i]
- if (i % x != 0)
- {
- c.push_back(a[i]);
- }
- }
- //we leave the rest of the elements in A
- a = c;
- c.clear();
- }
- //print the sequence A
- for (int x : a)
- {
- cout << x << " ";
- }
- cout << "-1";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement