Submission
Status:
P------x--
Score: 10
User: getsuki
Problemset: เรือสำราญ
Language: c
Time: 0.007 second
Submitted On: 2024-09-28 17:30:21
#include <stdio.h>
#include <stdbool.h>
#define true 1
#define false 0
bool between(int n, int a, int b){
int t = 0;
for(int i = a;i<=b + 1;i++){
if(i == n){
return 1;
}
}
return 0;
}
int main(){
int n, m;
scanf("%d %d", &n, &m);
int j;
scanf("%d", &j);
int a[j][2];
for(int i = 0;i<j;i++){
for(int z = 0;z<2;z++){
scanf("%d", &a[i][z]);
}
}
int cnt = 0;
int b[j];
for(int i = 0;i<j;i++){
b[i] = 0;
}
for(int i = m;i<=n;i = i + m){
int t = 1;
for(int z = 0;z<j;z++){
bool y = between(i, a[z][0], a[z][1]);
if(y)
t = 0;
break;
}
if(t == 1){
b[cnt] = i;
cnt++;
}
}
printf("%d\n", cnt - 1);
for(int i = 0;i<cnt - 1;i++){
printf("%d\n", b[i]);
}
}
//60 8
//3
//12 17
//25 30
//51 56