mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 13:58:48 +00:00
1799. [Ahoi2009] self 同类分布
https://hydro.ac/d/bzoj/record/6322adbfbdf9bc31d16061fa
This commit is contained in:
parent
58b85e4ba4
commit
320af422bd
55
BZOJ/1799/1799.cpp
Normal file
55
BZOJ/1799/1799.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <bitset>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
long long a, b, f[20][200][200], ans;
|
||||||
|
int c[20], p;
|
||||||
|
|
||||||
|
long long dfs(int len, int s, int x, bool limit) {
|
||||||
|
if (s + 9 * len < p) return 0;
|
||||||
|
if (!limit && f[len][s][x] != -1) return f[len][s][x];
|
||||||
|
if (!len) return s == p && x == 0;
|
||||||
|
|
||||||
|
int n = limit ? c[len] : 9;
|
||||||
|
long long res = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i <= n && i + s <= p; i++)
|
||||||
|
res += dfs(len - 1, s + i, (x * 10 + i) % p, limit && (i == c[len]));
|
||||||
|
|
||||||
|
if (!limit) f[len][s][x] = res;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long calc(long long x) {
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
while (x) {
|
||||||
|
c[++cnt] = x % 10;
|
||||||
|
x /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long res = 0;
|
||||||
|
|
||||||
|
for (p = 1; p <= cnt * 9; p++) {
|
||||||
|
memset(f, 0xff, sizeof(f));
|
||||||
|
res += dfs(cnt, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> a >> b;
|
||||||
|
|
||||||
|
cout << calc(b) - calc(a - 1) << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
BZOJ/1799/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1799/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1799/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user