problem cf 1800
由于每一位的和和顺序无关,所以枚举即可,
时间复杂度
O
(
n
l
o
g
n
)
O(nlogn)
O(nlogn)
// Decline is inevitable,
// Romance will last forever.
#include <bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define ll long long
#define LL long long
#define ld long double
#define endl '\n'
#define RE0 return 0
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define int long long
const int maxn = 1e6 + 10;
const int P = 1e9 + 7; //998244353
const int INF = 0x7f7f7f7f;
int fac[maxn];
int a, b, n;
bool judge(int c) {
while(c) {
int z = c % 10;
if(z != a && z != b) return false;
c /=10;
}
return true;
}
ll power(ll a, ll b) {
ll ans = 1 % P;
for (; b; b >>= 1) {
if (b & 1) ans = ans * a % P;
a = a * a % P;
}
return ans;
}
inline ll inv(ll x) {
return power(x, (ll)(P-2));
}
void solve() {
fac[0] = 1;
cin >> a >> b >> n;
for(int i =1 ; i <=n; i++) {
fac[i] = fac[i-1] * i % P;
}
int cnt = 0;
for(int i = 0; i <= n; i++) {
int c = a * i + b * (n-i);
if(judge(c)) {
cnt = (cnt + fac[n]*inv(fac[i])%P*inv(fac[n-i])%P)%P;
}
}
cout << cnt << endl;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// int T; scanf("%d", &T); while(T--)
// freopen("1channel00.txt","r",stdin);
// freopen("2.txt","w",stdout);
// int T; cin >> T; while(T--)
solve();
RE0;
}