Advertisement
dimuster

set d, f

Feb 21st, 2022
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. // D
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define int long long
  8. #define v vector
  9.  
  10.  
  11. signed main() {
  12.     ios_base::sync_with_stdio(false);
  13.     cin.tie(NULL);
  14. //    cout.setf(ios::fixed);
  15. //    cout.precision(6);
  16. //    freopen("input.txt", "r", stdin);
  17. //    freopen("output.txt", "w", stdout);
  18.    
  19.     set<int> yes;
  20.     set<int> no;
  21.     set<int> :: iterator it;
  22.    
  23.     int n;
  24.     cin >> n;
  25.    
  26.     for (int i = 1; i <= n; i++) yes.insert(i);
  27.    
  28.     vector<int> nums;
  29.     string s;
  30.     cin >> s;
  31.    
  32.     while (s != "HELP") {
  33.         if (s != "YES" and s != "NO") {
  34.             nums.push_back(stoi(s));
  35.         } else if (s == "YES") {
  36.             set<int> temp = yes;
  37.             yes.clear();
  38.             for (int i = 0; i < nums.size(); i++) {
  39.                 if (temp.find(nums[i]) != temp.end()) yes.insert(nums[i]);
  40.             }
  41.             nums.clear();
  42.         } else {
  43.             for (int i = 0; i < nums.size(); i++) no.insert(nums[i]);
  44.             nums.clear();
  45.         }
  46.         cin >> s;
  47.     }
  48.    
  49.     for (it = yes.begin(); it != yes.end(); it++) {
  50.         if (no.find(*it) == no.end()) cout << *it << " ";
  51.     }
  52.    
  53.     return 0;
  54. }
  55.  
  56.  
  57. // F
  58.  
  59. #include <bits/stdc++.h>
  60.  
  61. using namespace std;
  62.  
  63. #define int long long
  64. #define v vector
  65.  
  66.  
  67. signed main() {
  68.     ios_base::sync_with_stdio(false);
  69.     cin.tie(NULL);
  70. //    cout.setf(ios::fixed);
  71. //    cout.precision(6);
  72. //    freopen("input.txt", "r", stdin);
  73. //    freopen("output.txt", "w", stdout);
  74.    
  75.     set<int> xdays;
  76.    
  77.     int n, k;
  78.     cin >> n >> k;
  79.     while (k--) {
  80.         int first, step;
  81.         cin >> first >> step;
  82.         while (first <= n) {
  83.             xdays.insert(first);
  84.             first += step;
  85.         }
  86.     }
  87.    
  88.     for (int i = 6; i <= n; i += 7) {
  89.         xdays.erase(i);
  90.         xdays.erase(i + 1);
  91.     }
  92.    
  93.     cout << xdays.size();
  94.    
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement