結果

問題 No.391 CODING WAR
ユーザー hjgjkvkhjvvhgbxctgdhjgjkvkhjvvhgbxctgd
提出日時 2021-12-26 17:19:11
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 3,451 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 160,344 KB
実行使用メモリ 6,352 KB
最終ジャッジ日時 2023-10-24 12:13:49
合計ジャッジ時間 3,302 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,352 KB
testcase_01 AC 6 ms
6,352 KB
testcase_02 AC 7 ms
6,352 KB
testcase_03 AC 6 ms
6,352 KB
testcase_04 AC 7 ms
6,352 KB
testcase_05 AC 6 ms
6,352 KB
testcase_06 AC 6 ms
6,352 KB
testcase_07 AC 6 ms
6,352 KB
testcase_08 AC 6 ms
6,352 KB
testcase_09 AC 39 ms
6,352 KB
testcase_10 AC 32 ms
6,352 KB
testcase_11 AC 23 ms
6,352 KB
testcase_12 AC 6 ms
6,352 KB
testcase_13 AC 34 ms
6,352 KB
testcase_14 AC 32 ms
6,352 KB
testcase_15 AC 35 ms
6,352 KB
testcase_16 AC 24 ms
6,352 KB
testcase_17 AC 26 ms
6,352 KB
testcase_18 AC 20 ms
6,352 KB
testcase_19 AC 20 ms
6,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include <atcoder/all>
using namespace std;
//using namespace boost::multiprecision;
//using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);++i)
#define lep(i,n) for(long long i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end()
#define equals(a,b) (fabs((a)-(b))<eps)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
using ll=long long;
template<typename T> using vc = vector<T>;
template<typename T,typename U> using pp=pair<T,U>;
template<typename T> using PQ = priority_queue<T,vc<T>,greater<T>>;
using vi=vc<int> ;
using vvi=vc<vi>;
using vvvi=vc<vvi>;
using vl=vc<ll>;
using vvl=vc<vl>;
using vvvl=vc<vvl>;
using pi=pp<int,int>;
using pd=pp<double,double>;
using pl=pp<ll,ll>;
using pip=pp<int,pi>;
using vpi=vc<pi>;
using vvpi=vc<vpi>;
using vs=vc<string>;
using vss=vc<vs>;
using vst=vc<set<int>>;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int inf=1001001001;
const ll infl=100100100100100100;
const double eps=(1e-10);
const ll mod=1000000007;
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; }
template<typename T>
void rprint(T &a) {printf("%.10f\n",a);}
template<typename T>
void coutarray(vc<T>& v) { rep(i, sz(v)) {cout << " "; cout << v[i];} cout << endl; }
template<typename T>
void coutmatrix(vc<vc<T>>& v) { rep(i,sz(v)) { rep(j, sz(v[i])) {cout << " "; cout << v[i][j]; } cout << "\n";} };

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){
    return (*this)*=a.inv();
  }
  mint operator+(const mint &a) const{return mint(*this)+=a;}
  mint operator-(const mint &a) const{return mint(*this)-=a;}
  mint operator*(const mint &a) const{return mint(*this)*=a;}
  mint operator/(const mint &a) const{return mint(*this)/=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);}
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    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 || n <k) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= n; ++a) {
        if (n % a != 0) continue;
        long long ex = 0; 
        while (n % a == 0) {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if (n != 1) res.push_back({n, 1});
    return res;
}
using vpl=vector<pl>;
int main(){
  ll n,m;
  cin>>n>>m;
  mint now=0;
  combination com(200000);
  rep(i,m+1)now+=mint(i & 1 ? -1 : 1) * com(m, i) * mint(m-i).pow(n);
  cout<<now.x<<endl;
  return 0;
}
0