diff --git a/S2OJ/712/712.cpp b/S2OJ/712/712.cpp new file mode 100644 index 00000000..31c5d9a6 --- /dev/null +++ b/S2OJ/712/712.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/S2OJ/712/data/data1.in b/S2OJ/712/data/data1.in new file mode 100644 index 00000000..fab8725c --- /dev/null +++ b/S2OJ/712/data/data1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d15eb7a787b01293b694c4c3a6b91206671a27de8b28a5b85bca14272ff033b1 +size 10 diff --git a/S2OJ/712/data/data1.out b/S2OJ/712/data/data1.out new file mode 100644 index 00000000..c967da8a --- /dev/null +++ b/S2OJ/712/data/data1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48676967ad2bf967edfc789499188c6393617c42adee928be9e83e66e8585dbb +size 7 diff --git a/S2OJ/712/data/data10.in b/S2OJ/712/data/data10.in new file mode 100644 index 00000000..ffbdd04a --- /dev/null +++ b/S2OJ/712/data/data10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:021c7cd8d644bb1979cb51aac47e0b87f471cae8dae19f44e2b98c23f4343172 +size 18 diff --git a/S2OJ/712/data/data10.out b/S2OJ/712/data/data10.out new file mode 100644 index 00000000..c0480bc7 --- /dev/null +++ b/S2OJ/712/data/data10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed8ba1f545bea9fae9020344a571dffcc7fefc817d8fa4979606beee35661ff9 +size 10 diff --git a/S2OJ/712/data/data2.in b/S2OJ/712/data/data2.in new file mode 100644 index 00000000..8ba5cfe7 --- /dev/null +++ b/S2OJ/712/data/data2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41ee62bf70dd5f8042b36af3f893a6923093b7a8c83b2022c13dfabfa4b9795c +size 22 diff --git a/S2OJ/712/data/data2.out b/S2OJ/712/data/data2.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/S2OJ/712/data/data2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/S2OJ/712/data/data3.in b/S2OJ/712/data/data3.in new file mode 100644 index 00000000..4e997a8c --- /dev/null +++ b/S2OJ/712/data/data3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68d480ac6fe819c7716328d8eecd3f8f37bc11cbd81062a9958c3c2259dc0d1b +size 20 diff --git a/S2OJ/712/data/data3.out b/S2OJ/712/data/data3.out new file mode 100644 index 00000000..242b8675 --- /dev/null +++ b/S2OJ/712/data/data3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e87bd74311c96fc5361a0fcb111898e070de4ced84c75140dc07d6f2930ec04f +size 10 diff --git a/S2OJ/712/data/data4.in b/S2OJ/712/data/data4.in new file mode 100644 index 00000000..8249c5fe --- /dev/null +++ b/S2OJ/712/data/data4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:074f71134b5c683164765895fe22e454bfb5c347fff9df89910569154655e185 +size 10 diff --git a/S2OJ/712/data/data4.out b/S2OJ/712/data/data4.out new file mode 100644 index 00000000..f409cfe4 --- /dev/null +++ b/S2OJ/712/data/data4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca843265b3a238c71e4c641a8c2fe5ffb70912737ef6d00a72bc92662f03121e +size 6 diff --git a/S2OJ/712/data/data5.in b/S2OJ/712/data/data5.in new file mode 100644 index 00000000..3f10331c --- /dev/null +++ b/S2OJ/712/data/data5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:818c6feaa570f608e03763849ad365675587dbf9e5db62798c14e0152f6f42d5 +size 18 diff --git a/S2OJ/712/data/data5.out b/S2OJ/712/data/data5.out new file mode 100644 index 00000000..d8b60b97 --- /dev/null +++ b/S2OJ/712/data/data5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8759b5cf4e8997fcb60a7322b2379dbd944ce9f4b18cca7ded9e90e32d47802 +size 9 diff --git a/S2OJ/712/data/data6.in b/S2OJ/712/data/data6.in new file mode 100644 index 00000000..3a4b5475 --- /dev/null +++ b/S2OJ/712/data/data6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4602a5989c710756a3f13ce281045e92de01f97a982ee30ed793369ca04d32d +size 20 diff --git a/S2OJ/712/data/data6.out b/S2OJ/712/data/data6.out new file mode 100644 index 00000000..b0715ead --- /dev/null +++ b/S2OJ/712/data/data6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:931e58a3809521b05051375091c062ff3a081ba22501f37a96f24a5635375c69 +size 9 diff --git a/S2OJ/712/data/data7.in b/S2OJ/712/data/data7.in new file mode 100644 index 00000000..8e67cb08 --- /dev/null +++ b/S2OJ/712/data/data7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f504c984fe4c001c8be10a9f746a857e2286e31fee9512fa2bb50ec72efea584 +size 17 diff --git a/S2OJ/712/data/data7.out b/S2OJ/712/data/data7.out new file mode 100644 index 00000000..0fc22c97 --- /dev/null +++ b/S2OJ/712/data/data7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:268030dfdb67610eddda4c45403cb6debf1da1131dae1fa8bfd2ade97663f7a6 +size 10 diff --git a/S2OJ/712/data/data8.in b/S2OJ/712/data/data8.in new file mode 100644 index 00000000..4f3eedeb --- /dev/null +++ b/S2OJ/712/data/data8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a402e07b697c5f51ff14ffca943bac317f95e9fce85b95739756d44f72cf03b +size 13 diff --git a/S2OJ/712/data/data8.out b/S2OJ/712/data/data8.out new file mode 100644 index 00000000..b44836f5 --- /dev/null +++ b/S2OJ/712/data/data8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65e53df4c614b44d90b79f9e5095f746629a93489d061ed67d0666d1a345f073 +size 10 diff --git a/S2OJ/712/data/data9.in b/S2OJ/712/data/data9.in new file mode 100644 index 00000000..8531d6e5 --- /dev/null +++ b/S2OJ/712/data/data9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0549a361bcb79e9ff15299a8b63dc5e1bcaacc698f94e95d8c6117f75a4b6a17 +size 15 diff --git a/S2OJ/712/data/data9.out b/S2OJ/712/data/data9.out new file mode 100644 index 00000000..c09b1717 --- /dev/null +++ b/S2OJ/712/data/data9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a73c24b026c83f7153735093dde13b2710f998aa32584ca28dfef6dc5a21f8d6 +size 9 diff --git a/S2OJ/712/data/problem.conf b/S2OJ/712/data/problem.conf new file mode 100644 index 00000000..93f5eac4 --- /dev/null +++ b/S2OJ/712/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f48e35a3017e07d29988e70985b55c51e48431df2dd8db3f0386a6787d2d324e +size 193