結果
| 問題 |
No.1035 Color Box
|
| コンテスト | |
| ユーザー |
saswata de
|
| 提出日時 | 2020-04-24 22:50:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,639 bytes |
| コンパイル時間 | 1,620 ms |
| コンパイル使用メモリ | 171,048 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 03:19:13 |
| 合計ジャッジ時間 | 5,556 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 WA * 8 |
ソースコード
#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<<endl;
return 0;
}
saswata de