https://codeforces.com/problemset/problem/300/C
就是数位上的是好数,然后数位求和后的数,数位上也得是好数
满足关系
考虑n<=1e6,枚举x,找到符合条件的sum
得到x个a,(n-x)个b可以组合成极好数,组合方法数有
总组合方法数
// Problem: C. Beautiful Numbers
// Contest: Codeforces - Codeforces Round 181 (Div. 2)
// URL: https://codeforces.com/problemset/problem/300/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=9e6+9;
ll f[N],invf[N];
int a,b,n;
ll qmi(ll a,ll b){
ll res=1;
while(b){
if(b&1){
res=res*a%mod;
}
a=a*a%mod;
b>>=1;
}
return res;
}
ll inv(ll x){return qmi(x,mod-2)%mod;}
ll C(ll n,ll m){return (((f[n]*invf[m])%mod)*invf[n-m]%mod)%mod;}
bool check(ll x){
while(x){
ll t=x%10;
if(t!=a && t!=b){
return false;
}
x/=10;
}
return true;
}
void init(){
f[0]=1;
for(int i=1;i<=1000002;i++){
f[i]=f[i-1]*i%mod;
}
invf[1000001]=inv(f[1000001])%mod;
for(int i=1000000;i>=0;i--){
invf[i]=invf[i+1]*(i+1)%mod;//
}
}
int main(){
init();
cin>>a>>b>>n;
ll ans=0;
for(int i=0;i<=n;i++){
if(check(a*i+b*(n-i))){
ans+=(C(n,i));
ans%=mod;
}
}
cout<<ans%mod<<'\n';
return 0;
}