### [AtCoder] [經典競程 90 題] 005 - Restricted Digits（★7）

#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
using llu = uint64_t;
constexpr int M = 3000 + 5;
constexpr int N = 64;
constexpr int MOD = 1'000'000'007;

static inline int add(int x, int y, int mod = MOD) {
return x + y >= mod ? x + y - mod : x + y;
}
static inline void adde(int &x, int y, int mod = MOD) {
x += y;
if (x >= mod) x -= mod;
}
static inline int mul(int64_t x, int64_t y, int mod = MOD) {
return static_cast<int>(x * y % mod);
}

int dp[N][M];
int ans[M], tmp[M];

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

llu n; int b, k; cin >> n >> b >> k;
for (int i = 0; i < k; ++i) {
int c; cin >> c;
dp[0][c % b]++;
}

bool initialized = false;
if (n & 1) {
for (int i = 0; i < b; ++i)
ans[i] = dp[0][i];
initialized = true;
}

int mul10 = 10;
for (int i = 1; i < N; ++i) {
for (int x = 0; x < b; ++x) {
for (int y = 0; y < b; ++y) {
}
}

mul10 = mul(mul10, mul10, b);

if ((static_cast<llu>(1) << i) & n) {
if (not initialized) {
for (int x = 0; x < b; ++x)
ans[x] = dp[i][x];
initialized = true;
} else {
for (int x = 0; x < b; ++x) {
for (int y = 0; y < b; ++y) {
}
}
copy_n(tmp, b, ans);
memset(tmp, 0, sizeof(tmp));
}
}
}
cout << ans[0] << '\n';
return 0;
}


### 留言

1. They provide new gamers a one hundred pc deposit bonus match as much as} \$1,000 for sports betting, just use the bonus code CRYPTO100 on your 배트맨토토 first deposit utilizing Bitcoin. Whether you are be} on the lookout for high-value deposit bonuses or choose to check your luck on free spins, we've just the best US on line casino bonuses go well with|swimsuit} your|to fit your} style, all provided in USD. These are often focused at current gamers, however in some cases, a welcome provide could be be} themed in accordance with a popular slot sport, for instance. These bonuses are communicated via e-mail, banners in the on line casino foyer and on the on line casino website's promotions web page, so be sure to|make sure to|remember to} check these out. It is not needed to assert each single bonus the on line casino presents you.