結果
| 問題 |
No.3178 free sort
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-06-15 01:08:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 3,101 ms |
| コンパイル使用メモリ | 281,224 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-06-15 01:08:37 |
| 合計ジャッジ時間 | 5,030 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
#include <atcoder/modint>
using mint = atcoder::modint998244353;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
string s;
cin >> s;
vector<int> cnt(10, 0);
for (char c : s) cnt[c - '0']++;
vector<mint> fact(s.size() + 1, 1);
for (int i = 1; i <= s.size(); ++i) fact[i] = fact[i - 1] * i;
mint ans = fact[s.size()];
for (int i = 0; i < 10; ++i) ans /= fact[cnt[i]];
if (cnt[0] != 0) {
mint t = fact[s.size() - 1];
for (int i = 1; i < 10; ++i) t /= fact[cnt[i]];
t /= fact[cnt[0] - 1];
ans -= t;
}
cout << ans.val() << '\n';
return 0;
}
a01sa01to