题目链接:Codeforces 300C Beautiful Numbers
题意:给定两个数
a
和
思路:我们枚举
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#define PI acos(-1.0)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define fi first
#define se second
#define ll o<<1
#define rr o<<1|1
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 1e6 + 1;
const int pN = 1e6;// <= 10^7
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
void add(LL &x, LL y) { x += y; x %= MOD; }
LL fac[MAXN];
void getfac()
{
fac[0] = 1 % MOD;
for(LL i = 1; i < MAXN; i++)
fac[i] = fac[i-1] * i % MOD;
}
LL Pow(LL a, LL n)
{
LL ans = 1;
while(n)
{
if(n & 1)
ans = ans * a % MOD;
a = a * a % MOD;
n >>= 1;
}
return ans;
}
int n, a, b;
bool judge(int v) {
while(v) {
if(v % 10 != a && v % 10 != b) return false;
v /= 10;
}
return true;
}
LL C(LL n, LL m) {
return fac[n] * Pow(fac[m], MOD-2) % MOD * Pow(fac[n-m], MOD-2) % MOD;
}
int main()
{
getfac();
cin >> a >> b >> n;
LL ans = 0;
for(int i = 0; i <= n; i++) {
int v = a * i + b * (n-i);
if(judge(v)) {
add(ans, C(n, i));
}
}
cout << ans << endl;
return 0;
}