0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:28:47 +00:00

Compare commits

...

3 Commits

43 changed files with 342 additions and 0 deletions

74
BZOJ/1026/1026.cpp Normal file
View File

@ -0,0 +1,74 @@
#include <iostream>
#include <cmath>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 15;
int a, b, f[N][N];
std::vector<int> gen(int x) {
std::vector<int> 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;
}

BIN
BZOJ/1026/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1026/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

74
LibreOJ/10165/10165.cpp Normal file
View File

@ -0,0 +1,74 @@
#include <iostream>
#include <cmath>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 15;
int a, b, f[N][N];
std::vector<int> gen(int x) {
std::vector<int> 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;
}

BIN
LibreOJ/10165/data/windy0.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy0.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10165/data/windy9.out (Stored with Git LFS) Normal file

Binary file not shown.

74
Luogu/P2657/P2657.cpp Normal file
View File

@ -0,0 +1,74 @@
#include <iostream>
#include <cmath>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 15;
int a, b, f[N][N];
std::vector<int> gen(int x) {
std::vector<int> 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;
}