#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN \
freopen("in.txt", "r", stdin); \
freopen("out.txt", "w", stdout);
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case \
int T; \
cin >> T; \
rep(_, 1, T)
#define int ll
#define LL long long
#define int ll
inline int read() {
char tempt = getchar();
int x = 0, f = 0;
while (tempt < '0' || tempt > '9')
f |= tempt == '-', tempt = getchar();
while (tempt >= '0' && tempt <= '9')
x = x * 10 + tempt - '0', tempt = getchar();
return f ? -x : x;
}
int qmi(int m, int k) {
int res = 1, t = m;
while (k) {
if (k & 1)
res = res * t;
t = t * t;
k >>= 1;
}
return res;
}
int qmi(int a, int k, int p) { // 快速幂模板
int res = 1;
while (k) {
if (k & 1)
res = (LL) res * a % p;
a = (LL) a * a % p;
k >>= 1;
}
return res;
}
template <class T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int const N = 50010;
int prime[N];
bool st[N];
int sum[N];
int cnt = 0;
void get_primes(int n) {
for (int i = 2; i <= n; i++) {
if (!st[i])
prime[cnt++] = i;
for (int j = 0; prime[j] <= n / i; j++) {
st[prime[j]*i] = true;
if (i % prime[j] == 0)
break;
}
}
}
int get(int n, int p) {
int res = 0;
while (n) {
res += n / p;
n /= p;
}
return res;
}
vector<int> mul(vector<int> a, int b) {
vector<int> c;
int t = 0;
for (int i = 0; i < a.size(); i++) {
t += a[i] * b;
c.push_back(t % 10);
t /= 10;
}
while (t) {
c.push_back(t % 10);
t /= 10;
}
return c;
}
void C(int a, int b) {
get_primes(a);
for (int i = 0; i < cnt; i++) {
int p = prime[i];
sum[i] = get(a, p) - get(b, p) - get(a - b, p);
}
vector<int> res;
res.push_back(1);
for (int i = 0; i < cnt; i++)
for (int j = 0; j < sum[i]; j++)
res = mul(res, prime[i]);
for (int k = res.size() - 1; k >= 0; k--)
printf("%d", res[k]);
}
signed main() {
int k, x;
cin >> k >> x;
x = qmi(x, x, 1000);
int gb = k - 1;
int jg = 1;
int ans = 0;
int n = gb + x;
C(n - (gb - 1)*jg - 2, gb);
}
一本通1653:方程的解
最新推荐文章于 2024-08-26 00:02:00 发布