結果

問題 No.1035 Color Box
ユーザー nrvftnrvft
提出日時 2020-04-25 05:46:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,340 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 196,440 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2024-04-23 19:34:03
合計ジャッジ時間 3,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
5,888 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 16 ms
6,016 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 21 ms
6,016 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 15 ms
5,888 KB
testcase_12 WA -
testcase_13 AC 20 ms
6,016 KB
testcase_14 AC 22 ms
5,888 KB
testcase_15 AC 22 ms
5,888 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 21 ms
5,888 KB
testcase_20 WA -
testcase_21 AC 15 ms
5,888 KB
testcase_22 AC 15 ms
5,760 KB
testcase_23 AC 16 ms
5,888 KB
testcase_24 AC 16 ms
5,888 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 15 ms
5,888 KB
testcase_29 AC 16 ms
5,760 KB
testcase_30 WA -
testcase_31 AC 17 ms
5,888 KB
testcase_32 AC 16 ms
5,760 KB
testcase_33 AC 15 ms
5,888 KB
testcase_34 AC 16 ms
5,888 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 15 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 100005;
array<ll, MAX_SIZE> fac, inv, finv;
void fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[0] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % MOD;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }

ll dp[100005];

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    fac_init();

    ll ans = 0;
    rep(i,M+1){
        ans += comb(M, i) * modpow(i, N, MOD) % MOD * (i % 2 ? -1 : 1);
    }
    cout << (ans + MOD * MOD) % MOD << endl;
}
0