結果
問題 |
No.391 CODING WAR
|
ユーザー |
![]() |
提出日時 | 2023-05-05 12:17:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 1,767 bytes |
コンパイル時間 | 5,235 ms |
コンパイル使用メモリ | 307,020 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 21:53:58 |
合計ジャッジ時間 | 6,289 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#line 1 "main.cpp" #include <atcoder/all> #line 2 "library/src/template.hpp" #include<bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); i++) #define all(x) (x).begin(),(x).end() #define popcount(x) __builtin_popcount(x) using i128=__int128_t; using ll = long long; using ld = long double; using graph = std::vector<std::vector<int>>; using P = std::pair<int, int>; constexpr int inf = 1e9; constexpr ll infl = 1e18; constexpr ld eps = 1e-6; const long double pi = acos(-1); constexpr uint64_t MOD = 1e9 + 7; constexpr uint64_t MOD2 = 998244353; constexpr int dx[] = { 1,0,-1,0 }; constexpr int dy[] = { 0,1,0,-1 }; template<class T>constexpr inline void chmax(T&x,T y){if(x<y)x=y;} template<class T>constexpr inline void chmin(T&x,T y){if(x>y)x=y;} #line 3 "main.cpp" using namespace std; using mint = atcoder::modint1000000007; template <typename mint,int MAX> class combination { mint factorial[MAX + 1]; mint factorial_inv[MAX + 1]; public: constexpr explicit combination() noexcept { factorial[0] = 1; for (int i = 1; i <= MAX; ++i) { factorial[i] = factorial[i - 1] * i; } factorial_inv[MAX] = factorial[MAX].inv(); for (int i = MAX; i > 0; --i) { factorial_inv[i - 1] = factorial_inv[i] * i; } } constexpr mint com(int n, int r) const noexcept { assert(n >= r); return factorial[n] * factorial_inv[r] * factorial_inv[n - r]; } }; combination<mint, (int)1e5> com; int main() { ll n, m; cin >> n >> m; if (n < m) { puts("0"); return 0; } mint ans = 0; mint p = -1; for (int c = m; c >= 1; --c) { ans += (p *= -1) * com.com(m, c) * (mint(c).pow(n)); } cout << ans.val() << '\n'; }