Submission
Status:
P-P----PP-
Score: 40
User: Winzzwz
Problemset: เรือสำราญ
Language: cpp
Time: 0.010 second
Submitted On: 2024-11-13 13:50:57
#include <bits/stdc++.h>
using namespace std;
int k,t,n,s = 0, cnt;
unordered_map <int,bool> mark;
int main()
{
cin.tie(nullptr)->sync_with_stdio(false);
cin >> k >> t;
cin >> n;
cnt = t;
s = k/t;
while (n--) {
int u,v;
cin >> u >> v;
for (int i = u; i <= v; i++) {
if (i%t == 0) {s--; mark[i] = true;}
}
}
cout << s << "\n";
while (true) {
if (cnt > k) break;
if (!mark[cnt]) cout << cnt << "\n";
cnt += t;
}
return 0;
}