結果
| 問題 |
No.3178 free sort
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-21 00:57:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,355 bytes |
| コンパイル時間 | 3,851 ms |
| コンパイル使用メモリ | 255,828 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-21 00:57:55 |
| 合計ジャッジ時間 | 5,688 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define NP next_permutation
const int INF32 = 2e9;
const ll INF64 = 2e18;
const ll mod = 998244353;
// const ll mod = 1e9 + 7;
template<typename T> bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
void cincout() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
int main() {
cincout();
string S;
cin >> S;
int N = S.size();
using mint = modint998244353;
vector<mint> F(200001);
F[0] = 1;
for (int i = 0; i < 200000; i++) F[i + 1] = F[i] * (i + 1);
vector<ll> cnt(10);
for (char c : S) cnt[c - '0']++;
auto nCr = [&](ll n, ll r) -> mint {return F[n] * mint(F[n - r]).inv() * mint(F[r]).inv();};
mint ans = 1;
ll x = N;
for (int i = 0; i < 10; i++) {
if (i == 0) ans *= nCr(x - 1, cnt[i]);
else ans *= nCr(x, cnt[i]);
x -= cnt[i];
}
cout << ans.val() << endl;
}