//土尔逊Torson 编写于2023/4/5 #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <stdlib.h> int main() { int L, M; int tree[10001]; while (scanf("%d%d", &L, &M) != EOF) { for (int i = 0; i <= L; ++i) { tree[i] = 1; } int left, right; for (int idx = 0; idx < M; ++idx) { scanf("%d%d", &left, &right); for (left; left <= right; ++left) { tree[left] = 0; } } int total = 0; for (int j = 0; j <= L; ++j) { if (tree[j] == 1) { ++total; } } printf("%d\n", total); } system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")