結果
| 問題 |
No.986 Present
|
| コンテスト | |
| ユーザー |
kyort0n
|
| 提出日時 | 2020-02-11 16:05:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 268 ms / 2,000 ms |
| コード長 | 2,252 bytes |
| コンパイル時間 | 1,496 ms |
| コンパイル使用メモリ | 170,256 KB |
| 実行使用メモリ | 237,892 KB |
| 最終ジャッジ日時 | 2024-10-01 08:00:57 |
| 合計ジャッジ時間 | 8,984 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
//つぶあん つぶす
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 998244353;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
a %= mod;
if(b == 0){
return 1;
}
ll ans = beki(a, b / 2);
ans = ans * ans % mod;
if(b % 2 == 1){
ans = ans * a % mod;
}
return ans;
}
void init_combination(){
const int MAX = 10000002;
Factorial[0] = 1;
inv[0] = 1;
for(int i = 1; i <= MAX; i++){
Factorial[i] = Factorial[i - 1] * i % mod;
}
FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
for(ll i = MAX - 1; i >= 0; i--) {
FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
}
for(int i = 1; i <= MAX; i++) {
inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
}
}
ll combination(ll a, ll b){
if((a == b) || (b == 0)){
return 1;
}
if(a < b) return 0;
ll ans = Factorial[a] * FactorialInv[b] % mod;
ans = ans * FactorialInv[a - b] % mod;
return ans;
}
ll N, M;
ll ans[3];
void ANSWER() {
for(int i = 0; i < 3; i++) {
if(i != 0) cout << " ";
cout << ans[i];
}
cout << endl;
}
int main() {
//cout.precision(10);
cin.tie(0);
ios::sync_with_stdio(false);
init_combination();
cin >> N >> M;
ans[0] = beki(2, N);
ans[1] = 1;
ll factor = 1;
for(int i = 0; i < N; i++) {
ans[1] *= beki(2, M - i) - 1;
ans[1] %= mod;
ans[1] *= beki(2, i);
ans[1] %= mod;
factor *= beki(2, N - i) - 1;
factor %= mod;
factor *= beki(2, i);
factor %= mod;
}
ans[1] *= FactorialInv[N];
ans[1] %= mod;
factor *= FactorialInv[N];
factor %= mod;
ans[2] = ans[1] * beki(factor, mod - 2) % mod;
ANSWER();
return 0;
}
kyort0n