From 7cbea0786a4d91708ce78bfab68b97e5f8ff7495 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 21 Nov 2021 14:51:47 +0800 Subject: [PATCH] =?UTF-8?q?P1047=20[NOIP2005=20=E6=99=AE=E5=8F=8A=E7=BB=84?= =?UTF-8?q?]=20=E6=A0=A1=E9=97=A8=E5=A4=96=E7=9A=84=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R63269725 --- Luogu/P1047/P1047.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Luogu/P1047/P1047.cpp diff --git a/Luogu/P1047/P1047.cpp b/Luogu/P1047/P1047.cpp new file mode 100644 index 00000000..40e60480 --- /dev/null +++ b/Luogu/P1047/P1047.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int l, m, u, v, ans; +bool t[10005]; + +int main() { + cin >> l >> m; + for (int i = 0; i < m; i++) { + cin >> u >> v; + for (int j = u; j <= v; j++) { + t[j] = true; + } + } + for (int i = 0; i <= l; i++) { + ans += !t[i]; + } + cout << ans << endl; + return 0; +}