比赛 2025.12.13 评测结果 AAWWWWWWWW
题目名称 勇者 最终得分 20
用户昵称 LikableP 运行时间 0.015 s
代码语言 C++ 内存使用 1.52 MiB
提交时间 2025-12-13 11:12:43
显示代码纯文本
#include <cstdio>
#include <cctype>

template <typename T> T read() {
  T res = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
  return res * f;
}

void write(__int128 x, char ed = '\n') {
  if (x < 0) x = -x, putchar('-');
  static int sta[64], top = 0;
  do {
    sta[++top] = x % 10;
    x /= 10;
  } while (x);
  while (top) {
    putchar(sta[top--] ^ 48);
  }
  putchar(ed);
}

template <typename T> void write(T x, char ed = '\n') {
  write((__int128)x, ed);
}

typedef long long ll;

const ll MOD = 1e9 + 7;

ll kasumi(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}

ll n, m;
ll frac[310];

int main() {
  #ifdef LOCAL
    freopen("!input.in", "r", stdin);
    freopen("!output.out", "w", stdout);
  #else
    freopen("rotk.in", "r", stdin);
    freopen("rotk.out", "w", stdout);
  #endif

  frac[0] = 1;
  for (int i = 1; i <= 300; ++i) {
    frac[i] = frac[i - 1] * i % MOD;
  }

  n = read<ll>(), m = read<ll>();

  write(frac[n - 1] * kasumi(m - n + 1, m - n + 1) % MOD);
  return 0;
}