結果

問題 No.1035 Color Box
ユーザー NrKmDevNrKmDev
提出日時 2020-04-24 22:35:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 2,235 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 168,760 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 03:40:51
合計ジャッジ時間 3,073 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
6,812 KB
testcase_01 AC 6 ms
6,944 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 8 ms
6,944 KB
testcase_04 AC 8 ms
6,948 KB
testcase_05 AC 7 ms
6,940 KB
testcase_06 AC 7 ms
6,940 KB
testcase_07 AC 7 ms
6,940 KB
testcase_08 AC 24 ms
6,940 KB
testcase_09 AC 14 ms
6,940 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 22 ms
6,940 KB
testcase_14 AC 26 ms
6,940 KB
testcase_15 AC 27 ms
6,944 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 AC 7 ms
6,944 KB
testcase_19 AC 26 ms
6,944 KB
testcase_20 AC 6 ms
6,944 KB
testcase_21 AC 7 ms
6,944 KB
testcase_22 AC 6 ms
6,940 KB
testcase_23 AC 7 ms
6,944 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 6 ms
6,940 KB
testcase_27 AC 7 ms
6,940 KB
testcase_28 AC 7 ms
6,944 KB
testcase_29 AC 6 ms
6,940 KB
testcase_30 AC 6 ms
6,944 KB
testcase_31 AC 6 ms
6,940 KB
testcase_32 AC 6 ms
6,940 KB
testcase_33 AC 6 ms
6,940 KB
testcase_34 AC 7 ms
6,944 KB
testcase_35 AC 6 ms
6,944 KB
testcase_36 AC 7 ms
6,940 KB
testcase_37 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド:(典型)dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};

int main(){
    ll n,m;cin>>n>>m;
    combination c(200100);
    mint sum=0;
    for(int i=1;i<=m;i++){
        mint num=c(m,i)*mint(i).pow(n);
        sum=num-sum;
    }
    cout<<sum.x<<endl;
    return 0;
}
0