結果
問題 |
No.3178 free sort
|
ユーザー |
![]() |
提出日時 | 2025-06-13 21:37:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 1,046 bytes |
コンパイル時間 | 3,105 ms |
コンパイル使用メモリ | 281,856 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-13 21:37:08 |
合計ジャッジ時間 | 6,886 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 40 |
ソースコード
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <atcoder/modint> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(a) (a).begin(), (a).end() using ll = long long; const ll INF32 = 2e9; const ll INF64 = 4e18; using namespace atcoder; using mint = modint998244353; void printYN(bool ok){ if(ok)cout << "Yes" << endl; else cout << "No" << endl; return; } int main() { string N; cin >> N; mint ans, temp; ans = 1;temp = 1; vector<int> cnt(10); for(int i = 0; i < N.size(); i++){ cnt[N[i]-'0']++; } for(int i = 1; i <= N.size(); i++){ ans*=i; temp*=i; } if(cnt[0]>=1)temp/=N.size(); for(int i = 1; i <= cnt[0]; i++){ ans/=i; temp/=i; } if(cnt[0]>=1)temp*=cnt[0]; for(int i = 1; i < cnt.size(); i++){ for(int j = 1; j <= cnt[i]; j++){ ans/= j; temp/= j; } } if(cnt[0]==0)temp = 0; ans -= temp; cout << ans.val() << endl; return 0; }