#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define int long long usingnamespace std; constint MAXN = 2000005; constint Mod = 1e9 + 7;
int n, m, ans;
intqpow(int x, int y){ int res = 1; while (y) { if (y & 1) res = res * x % Mod; x = x * x % Mod; y >>= 1; } return res; }
intC(int x, int y){
if ((x - y) > (x - (x - y))) y = x - y;
int res = 1ll; for (int i = y + 1; i <= x; i++) { res = (res * (i % Mod)) % Mod; }
for (int i = 1; i <= x - y; i++) { res = (res * qpow(i, Mod - 2) % Mod); }
C[0][0] = 1; for (int i = 1; i <= 50; i++) { C[i][0] = 1; for (int j = 1; j <= i; j++) { C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; } }
scanf("%s", s + 1); n = strlen(s + 1); for (int i = 1; i <= n; i++) { tot[s[i] - 48]++; }
for (int i = 1; i <= n; i++) { for (int j = 0; j < s[i] - 48; j++) if(tot[j] > 0) { tot[j]--; int res = 1, sum = n - i; for(int k = 0; k <= 9; k++) { res *= C[sum][sum - tot[k]]; sum -= tot[k]; } tot[j]++; ans += res; } tot[s[i] - 48]--; }
#include<cstdio> #include<iostream> #include<algorithm> #define int long long #define LL long long usingnamespace std; constint MAXN = 1e5 + 5; constint Mod = 998244353;
int t, n, m, k;
LL fac[MAXN << 1], inv[MAXN << 1], ans;
LL qpow(LL x, int y){ LL res = 1; while (y) { if (y & 1) res = res * x % Mod; x = x * x % Mod; y >>= 1; } return res; }
LL C(int x, int y){ if (y > x) return0; if (x < 0 || y < 0) return0; return fac[x] * inv[y] % Mod * inv[x - y] % Mod; }
fac[0] = inv[0] = 1; for (int i = 1; i <= 2e5; i++) fac[i] = fac[i - 1] * i % Mod; inv[200000] = qpow(fac[200000], Mod - 2); for (int i = 2e5 - 1; i >= 1; i--) inv[i] = inv[i + 1] * (i + 1) % Mod;
scanf("%lld", &t);
while (t--) { scanf("%lld %lld %lld", &n, &m, &k); LL ans = C(k + m - 1, m - 1); for (int i = 1, sta = -1; i <= m; i++, sta *= -1) { ans = (ans + C(k + m - 1 - i * n, m - 1) * C(m, i) * (sta) + Mod) % Mod; } printf("%lld\n", ans); }
#include<ctime> #include<cstdio> #include<iostream> #include<algorithm> #define LL long long usingnamespace std; constint MAXN = 2e6 + 5;
int n, tot[MAXN], cnt, ans, sum;
structnode { int v[6], wid; unsignedlonglong key; } s[MAXN], tmp[MAXN];
boolcheck(int x, int y){ bool flag = true; for (int i = 1; i <= 5; i++) if(tmp[x].v[i] != tmp[y].v[i]) { flag = false; break; } return flag; }
boolcmp(node x, node y){ if (x.wid != y.wid) return x.wid < y.wid; // 哈哈,sort直接TLE // for (int i = 1; i <= 5; i++) { // if (x.v[i] != y.v[i]) { // return x.v[i] < y.v[i]; // } // } // return true; return x.key < y.key; }
voidread(int& x){ x = 0; int f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -f; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); } x *= f; }