結果

問題 No.1035 Color Box
ユーザー saswata desaswata de
提出日時 2020-04-26 21:44:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,657 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 172,236 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 09:20:42
合計ジャッジ時間 5,464 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
5,248 KB
testcase_01 AC 63 ms
5,376 KB
testcase_02 AC 64 ms
5,376 KB
testcase_03 AC 68 ms
5,376 KB
testcase_04 AC 70 ms
5,376 KB
testcase_05 AC 68 ms
5,376 KB
testcase_06 AC 68 ms
5,376 KB
testcase_07 AC 68 ms
5,376 KB
testcase_08 AC 101 ms
5,376 KB
testcase_09 AC 81 ms
5,376 KB
testcase_10 AC 67 ms
5,376 KB
testcase_11 AC 68 ms
5,376 KB
testcase_12 AC 68 ms
5,376 KB
testcase_13 AC 94 ms
5,376 KB
testcase_14 AC 100 ms
5,376 KB
testcase_15 AC 105 ms
5,376 KB
testcase_16 AC 67 ms
5,376 KB
testcase_17 AC 66 ms
5,376 KB
testcase_18 AC 67 ms
5,376 KB
testcase_19 AC 105 ms
5,376 KB
testcase_20 AC 67 ms
5,376 KB
testcase_21 AC 67 ms
5,376 KB
testcase_22 AC 67 ms
5,376 KB
testcase_23 AC 67 ms
5,376 KB
testcase_24 AC 67 ms
5,376 KB
testcase_25 AC 68 ms
5,376 KB
testcase_26 AC 67 ms
5,376 KB
testcase_27 AC 67 ms
5,376 KB
testcase_28 AC 67 ms
5,376 KB
testcase_29 AC 67 ms
5,376 KB
testcase_30 AC 67 ms
5,376 KB
testcase_31 AC 68 ms
5,376 KB
testcase_32 AC 62 ms
5,376 KB
testcase_33 AC 67 ms
5,376 KB
testcase_34 AC 67 ms
5,376 KB
testcase_35 AC 67 ms
5,376 KB
testcase_36 AC 67 ms
5,376 KB
testcase_37 AC 67 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define rep(it,a) for(auto it: a)
#define pb emplace_back
#define mp make_pair
#define vll vector<ll>
#define pll pair<ll,ll>
#define MOD (1000LL*1000*1000+7)
#define INF (MOD*MOD)
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define tri pair<ll,pll>
#define vpll vector<pll>
#define vvll vector<vll>
#define LL(t) ll t;cin>>t
#define VLL(v,n) vll v(n);f(i,0,n){cin>>v[i];}

ll power(ll a, ll b, ll mod) { // return (a^b)%mod
    if(b==0) return 1;
    ll half=power(a,b / 2,mod);
    ll full=(half*half)%mod;
    return (b%2) ? (a*full)%mod : full;
}

ll divMod(ll a, ll b, ll mod){ // return (a/b) % mod , works iff a%b=0
    return ((a%mod)*(power(b, MOD-2, MOD)))%mod;
}

bool comp(tri & a, tri &b){
    if(a.first!=b.first)
        return a.first < b.first;
    else{
        if(a.S.F!=b.S.F)
            return a.S.F < b.S.F;
        else
            return a.S.S < b.S.S;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    LL(n);LL(m);
    vll fact(100001), factInv(100001);
    fact[0]=factInv[0]=1;
    f(i,1,100001){
        fact[i]=(fact[i-1]*i)%MOD;
        factInv[i]=power(fact[i],MOD-2,MOD);
    }
    ll sum=0;
    f(i,0,m){
        ll x=(((((fact[m]*power(m-i,n,MOD))%MOD)*factInv[i])%MOD)*factInv[m-i])%MOD;
        if(i%2){
            sum-=x;
        } else
            sum+=x;
        sum%=MOD;
    }
    cout<<((sum<0)?sum+MOD:sum)<<endl;
    return 0;
}
0