标签:include mat com algo etc 推出 -- pre put
通俗易懂
()¥#)@()&%()@¥#()&¥#&@()#%&%
&¥#……%@#¥#@¥@%&
我们可以看出一位数有5 个两位数有25个
n位数有5^n个, 显然我们可以推出
我们对 \(C_n^m\)得到的数,不断地%5 /5
对每一次%5 得到的余数就是答案
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#define int long long
#define rr register
#define inf 1e9
#define MAXN 100010
using namespace std;
inline int read(int &T) {
int s = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= ch == ‘-‘, ch = getchar();
while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
return T = f ? -s : s;
}
const int mod = 1e9 + 7;
void print(int x) {
if (x < 0) putchar(‘-‘), x = -x;
if (x > 9) print(x / 10);
putchar(x % 10 + 48);
}
int t, n, m;
int a[10];
int c[200][200];
inline int init() {
a[1] = 1;
a[2] = 2;
a[3] = 3;
a[4] = 5;
a[0] = 9;
for (rr int i = 0; i <= 100; i++) c[i][0] = 1;
for (rr int i = 1; i <= 100; i++)
for (rr int j = 1; j <= 100; j++)
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
void pr(int x) {
if (x > 5) {
if (x % 5 != 0)
pr(x / 5);
else pr(x / 5 - 1);
}
cout << a[x % 5];
}
signed main() {
init();
t = read(t);
while (t--) {
n = read(n);
m = read(m);
pr(c[n][m]);
puts("");
}
}
nowcoder acm contest 5881 B 莫得难题
标签:include mat com algo etc 推出 -- pre put
原文地址:https://www.cnblogs.com/zzz-hhh/p/13052576.html