//给出一段距离,即是树木的总数,然后再给出几个树木需要砍伐或者移走的区域,求剩下的树木数!注意: //That's to say that there used to be 301 trees on the road. Now the section from 100m to 200m //is assigned for subway station, so 101 trees need to be moved away and only 200 trees are left. #include <iostream> using namespace std; int main() { int l, m, i, s1, s2, ans, tmp; while (cin >> l >> m){ if (l == 0 && m == 0) break; ans = 0; for (i = 0; i < m; i++){ cin >> s1 >> s2; tmp = s2 - s1; ans += tmp + 1; } ans = l + 1 - ans; cout << ans << endl; } system("pause"); }