From e62d247431639d2794e7169f8f5c21a6d669e294 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 4 Sep 2022 20:05:56 +0800 Subject: [PATCH] =?UTF-8?q?1026.=20[SCOI2009]windy=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hydro.ac/d/bzoj/record/6314946288397a179b6011c0 --- BZOJ/1026/1026.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++ BZOJ/1026/data/1.in | 3 ++ BZOJ/1026/data/1.out | 3 ++ BZOJ/1026/data/10.in | 3 ++ BZOJ/1026/data/10.out | 3 ++ BZOJ/1026/data/2.in | 3 ++ BZOJ/1026/data/2.out | 3 ++ BZOJ/1026/data/3.in | 3 ++ BZOJ/1026/data/3.out | 3 ++ BZOJ/1026/data/4.in | 3 ++ BZOJ/1026/data/4.out | 3 ++ BZOJ/1026/data/5.in | 3 ++ BZOJ/1026/data/5.out | 3 ++ BZOJ/1026/data/6.in | 3 ++ BZOJ/1026/data/6.out | 3 ++ BZOJ/1026/data/7.in | 3 ++ BZOJ/1026/data/7.out | 3 ++ BZOJ/1026/data/8.in | 3 ++ BZOJ/1026/data/8.out | 3 ++ BZOJ/1026/data/9.in | 3 ++ BZOJ/1026/data/9.out | 3 ++ 21 files changed, 134 insertions(+) create mode 100644 BZOJ/1026/1026.cpp create mode 100644 BZOJ/1026/data/1.in create mode 100644 BZOJ/1026/data/1.out create mode 100644 BZOJ/1026/data/10.in create mode 100644 BZOJ/1026/data/10.out create mode 100644 BZOJ/1026/data/2.in create mode 100644 BZOJ/1026/data/2.out create mode 100644 BZOJ/1026/data/3.in create mode 100644 BZOJ/1026/data/3.out create mode 100644 BZOJ/1026/data/4.in create mode 100644 BZOJ/1026/data/4.out create mode 100644 BZOJ/1026/data/5.in create mode 100644 BZOJ/1026/data/5.out create mode 100644 BZOJ/1026/data/6.in create mode 100644 BZOJ/1026/data/6.out create mode 100644 BZOJ/1026/data/7.in create mode 100644 BZOJ/1026/data/7.out create mode 100644 BZOJ/1026/data/8.in create mode 100644 BZOJ/1026/data/8.out create mode 100644 BZOJ/1026/data/9.in create mode 100644 BZOJ/1026/data/9.out diff --git a/BZOJ/1026/1026.cpp b/BZOJ/1026/1026.cpp new file mode 100644 index 00000000..31c5d9a6 --- /dev/null +++ b/BZOJ/1026/1026.cpp @@ -0,0 +1,74 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 15; + +int a, b, f[N][N]; + +std::vector gen(int x) { + std::vector res; + + while (x) { + res.push_back(x % 10); + x /= 10; + } + + return res; +} + +int calc(int x) { + int res = 0; + auto num = gen(x); + + for (int i = 1; i < num.size(); i++) { + for (int j = 1; j < 10; j++) { + res += f[i][j]; + } + } + + for (int i = 1; i < *num.rbegin(); i++) { + res += f[num.size()][i]; + } + + for (int i = num.size() - 1; i; i--) { + for (int j = 0; j < num[i - 1]; j++) { + if (std::abs(j - num[i]) >= 2) { + res += f[i][j]; + } + } + + if (std::abs(num[i] - num[i - 1]) < 2) break; + } + + return res; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> a >> b; + + for (int i = 0; i < 10; i++) { + f[1][i] = 1; + } + + for (int i = 2; i <= 10; i++) { + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 10; k++) { + if (std::abs(j - k) >= 2) { + f[i][j] += f[i - 1][k]; + } + } + } + } + + cout << calc(b + 1) - calc(a) << endl; + + return 0; +} diff --git a/BZOJ/1026/data/1.in b/BZOJ/1026/data/1.in new file mode 100644 index 00000000..fab8725c --- /dev/null +++ b/BZOJ/1026/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d15eb7a787b01293b694c4c3a6b91206671a27de8b28a5b85bca14272ff033b1 +size 10 diff --git a/BZOJ/1026/data/1.out b/BZOJ/1026/data/1.out new file mode 100644 index 00000000..c967da8a --- /dev/null +++ b/BZOJ/1026/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48676967ad2bf967edfc789499188c6393617c42adee928be9e83e66e8585dbb +size 7 diff --git a/BZOJ/1026/data/10.in b/BZOJ/1026/data/10.in new file mode 100644 index 00000000..ffbdd04a --- /dev/null +++ b/BZOJ/1026/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:021c7cd8d644bb1979cb51aac47e0b87f471cae8dae19f44e2b98c23f4343172 +size 18 diff --git a/BZOJ/1026/data/10.out b/BZOJ/1026/data/10.out new file mode 100644 index 00000000..c0480bc7 --- /dev/null +++ b/BZOJ/1026/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed8ba1f545bea9fae9020344a571dffcc7fefc817d8fa4979606beee35661ff9 +size 10 diff --git a/BZOJ/1026/data/2.in b/BZOJ/1026/data/2.in new file mode 100644 index 00000000..8ba5cfe7 --- /dev/null +++ b/BZOJ/1026/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41ee62bf70dd5f8042b36af3f893a6923093b7a8c83b2022c13dfabfa4b9795c +size 22 diff --git a/BZOJ/1026/data/2.out b/BZOJ/1026/data/2.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/BZOJ/1026/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/BZOJ/1026/data/3.in b/BZOJ/1026/data/3.in new file mode 100644 index 00000000..4e997a8c --- /dev/null +++ b/BZOJ/1026/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68d480ac6fe819c7716328d8eecd3f8f37bc11cbd81062a9958c3c2259dc0d1b +size 20 diff --git a/BZOJ/1026/data/3.out b/BZOJ/1026/data/3.out new file mode 100644 index 00000000..242b8675 --- /dev/null +++ b/BZOJ/1026/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e87bd74311c96fc5361a0fcb111898e070de4ced84c75140dc07d6f2930ec04f +size 10 diff --git a/BZOJ/1026/data/4.in b/BZOJ/1026/data/4.in new file mode 100644 index 00000000..8249c5fe --- /dev/null +++ b/BZOJ/1026/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:074f71134b5c683164765895fe22e454bfb5c347fff9df89910569154655e185 +size 10 diff --git a/BZOJ/1026/data/4.out b/BZOJ/1026/data/4.out new file mode 100644 index 00000000..f409cfe4 --- /dev/null +++ b/BZOJ/1026/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca843265b3a238c71e4c641a8c2fe5ffb70912737ef6d00a72bc92662f03121e +size 6 diff --git a/BZOJ/1026/data/5.in b/BZOJ/1026/data/5.in new file mode 100644 index 00000000..3f10331c --- /dev/null +++ b/BZOJ/1026/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:818c6feaa570f608e03763849ad365675587dbf9e5db62798c14e0152f6f42d5 +size 18 diff --git a/BZOJ/1026/data/5.out b/BZOJ/1026/data/5.out new file mode 100644 index 00000000..d8b60b97 --- /dev/null +++ b/BZOJ/1026/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8759b5cf4e8997fcb60a7322b2379dbd944ce9f4b18cca7ded9e90e32d47802 +size 9 diff --git a/BZOJ/1026/data/6.in b/BZOJ/1026/data/6.in new file mode 100644 index 00000000..3a4b5475 --- /dev/null +++ b/BZOJ/1026/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4602a5989c710756a3f13ce281045e92de01f97a982ee30ed793369ca04d32d +size 20 diff --git a/BZOJ/1026/data/6.out b/BZOJ/1026/data/6.out new file mode 100644 index 00000000..b0715ead --- /dev/null +++ b/BZOJ/1026/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:931e58a3809521b05051375091c062ff3a081ba22501f37a96f24a5635375c69 +size 9 diff --git a/BZOJ/1026/data/7.in b/BZOJ/1026/data/7.in new file mode 100644 index 00000000..8e67cb08 --- /dev/null +++ b/BZOJ/1026/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f504c984fe4c001c8be10a9f746a857e2286e31fee9512fa2bb50ec72efea584 +size 17 diff --git a/BZOJ/1026/data/7.out b/BZOJ/1026/data/7.out new file mode 100644 index 00000000..0fc22c97 --- /dev/null +++ b/BZOJ/1026/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:268030dfdb67610eddda4c45403cb6debf1da1131dae1fa8bfd2ade97663f7a6 +size 10 diff --git a/BZOJ/1026/data/8.in b/BZOJ/1026/data/8.in new file mode 100644 index 00000000..4f3eedeb --- /dev/null +++ b/BZOJ/1026/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a402e07b697c5f51ff14ffca943bac317f95e9fce85b95739756d44f72cf03b +size 13 diff --git a/BZOJ/1026/data/8.out b/BZOJ/1026/data/8.out new file mode 100644 index 00000000..b44836f5 --- /dev/null +++ b/BZOJ/1026/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65e53df4c614b44d90b79f9e5095f746629a93489d061ed67d0666d1a345f073 +size 10 diff --git a/BZOJ/1026/data/9.in b/BZOJ/1026/data/9.in new file mode 100644 index 00000000..8531d6e5 --- /dev/null +++ b/BZOJ/1026/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0549a361bcb79e9ff15299a8b63dc5e1bcaacc698f94e95d8c6117f75a4b6a17 +size 15 diff --git a/BZOJ/1026/data/9.out b/BZOJ/1026/data/9.out new file mode 100644 index 00000000..c09b1717 --- /dev/null +++ b/BZOJ/1026/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a73c24b026c83f7153735093dde13b2710f998aa32584ca28dfef6dc5a21f8d6 +size 9