From 0c63ada187ca9631b508d1fd9feb0a96d839932e Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Fri, 11 Feb 2022 22:21:22 +0800 Subject: [PATCH] =?UTF-8?q?P2010=20[NOIP2016=20=E6=99=AE=E5=8F=8A=E7=BB=84?= =?UTF-8?q?]=20=E5=9B=9E=E6=96=87=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R69127852 --- Luogu/P2010/P2010.cpp | 35 +++++++++++++++++++++++++++++++++++ Luogu/P2010/data/P2010_9.in | 3 +++ Luogu/P2010/data/P2010_9.out | 3 +++ 3 files changed, 41 insertions(+) create mode 100644 Luogu/P2010/P2010.cpp create mode 100644 Luogu/P2010/data/P2010_9.in create mode 100644 Luogu/P2010/data/P2010_9.out diff --git a/Luogu/P2010/P2010.cpp b/Luogu/P2010/P2010.cpp new file mode 100644 index 00000000..614c6324 --- /dev/null +++ b/Luogu/P2010/P2010.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +struct node { + int year, month, day; +} date1, date2; + +using namespace std; + +int ans; +std::string s1, s2; + +int main() { + scanf("%4d%2d%2d", &date1.year, &date1.month, &date1.day); + scanf("%4d%2d%2d", &date2.year, &date2.month, &date2.day); + for (int yy = date1.year; yy <= date2.year; yy++) { + for (int mm = (yy == date1.year ? date1.month : 1); + mm <= (yy == date2.year ? date2.month : 12); + mm++) { + for (int dd = (yy == date1.year && mm == date1.month ? date1.day : 1); + dd <= (yy == date2.year && mm == date2.month ? date2.day : days[mm]); + dd++) { + s1 = s2 = std::to_string(yy * 10000 + mm * 100 + dd); + std::reverse(s2.begin(), s2.end()); + if (s1 == s2) ans++; + } + } + } + printf("%d\n", ans); + return 0; +} diff --git a/Luogu/P2010/data/P2010_9.in b/Luogu/P2010/data/P2010_9.in new file mode 100644 index 00000000..9ef1231a --- /dev/null +++ b/Luogu/P2010/data/P2010_9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c50219be09140332a2c6c21fa73f565196ccb6f65f726684bcba752e6dc3dff +size 18 diff --git a/Luogu/P2010/data/P2010_9.out b/Luogu/P2010/data/P2010_9.out new file mode 100644 index 00000000..1bfa7175 --- /dev/null +++ b/Luogu/P2010/data/P2010_9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d030dea268935dbd3e2db7c17196757924d0463c5800349904bc5dcf538e1149 +size 4