Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // D
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define v vector
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- // cout.setf(ios::fixed);
- // cout.precision(6);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- set<int> yes;
- set<int> no;
- set<int> :: iterator it;
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++) yes.insert(i);
- vector<int> nums;
- string s;
- cin >> s;
- while (s != "HELP") {
- if (s != "YES" and s != "NO") {
- nums.push_back(stoi(s));
- } else if (s == "YES") {
- set<int> temp = yes;
- yes.clear();
- for (int i = 0; i < nums.size(); i++) {
- if (temp.find(nums[i]) != temp.end()) yes.insert(nums[i]);
- }
- nums.clear();
- } else {
- for (int i = 0; i < nums.size(); i++) no.insert(nums[i]);
- nums.clear();
- }
- cin >> s;
- }
- for (it = yes.begin(); it != yes.end(); it++) {
- if (no.find(*it) == no.end()) cout << *it << " ";
- }
- return 0;
- }
- // F
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define v vector
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- // cout.setf(ios::fixed);
- // cout.precision(6);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- set<int> xdays;
- int n, k;
- cin >> n >> k;
- while (k--) {
- int first, step;
- cin >> first >> step;
- while (first <= n) {
- xdays.insert(first);
- first += step;
- }
- }
- for (int i = 6; i <= n; i += 7) {
- xdays.erase(i);
- xdays.erase(i + 1);
- }
- cout << xdays.size();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement