結果
問題 |
No.3178 free sort
|
ユーザー |
|
提出日時 | 2025-06-13 22:31:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 2,450 bytes |
コンパイル時間 | 1,797 ms |
コンパイル使用メモリ | 198,276 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-13 22:32:02 |
合計ジャッジ時間 | 3,571 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 40 |
ソースコード
#ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ int main(void) { string s; cin>>s; ll n=s.size(); vl ct(10); rep(i,n) ct[s[i]-'0']++; factset fs((ll)s.size()); ll d=1; rep(D,10) { d=d*fs.fact(ct[D])%mod; } ll ans=fs.fact(n-1); ans=ans*(n-ct[0])%mod; ans=ans*modpow(d,998244351ll,1)%mod; cout<<ans<<nl; } /////// library zone /////// #else #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define srep(i,l,r) for(ll i=l;i<=r;i++) using ll = long long; using ld = long double; const ll mod=998244353; #define vout(v) for(auto i :v) cout<<i<<" "; #define INF 9223300000000000000ll #define Winf 5e12 #define nl "\n" #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define vl vector<ll> #define vc vector<char> #define pb push_back ll modpow(ll fl, ll po, ll mode) { // mode: 0=modなし, 1=modあり ll ret=1; if (mode) { while (po>0) { if (po&1) ret=(ret*fl)%mod; fl=(fl*fl)%mod; po>>=1; } } else { while (po>0) { if(po&1) ret*=fl; fl*=fl; po>>=1; } } return ret; } class factset { public: vl _fact; vl _inv; ll __n; factset(ll n):_fact(n+1),_inv(n+1),__n(n) { _fact[0]=1; srep(i,1,__n) { _fact[i]=_fact[i-1]*i; _fact[i]%=mod; } _inv[__n]=modpow(_fact[__n],mod-2,1); for(int i=__n-1;i>=0;i--) { _inv[i]=_inv[i+1]*(i+1); _inv[i]%=mod; } } ll fact(ll x) { assert(0<=x && x<=__n); return _fact[x]; } ll inv(ll x) { assert(0<=x && x<=__n); return _inv[x]; } ll comb(ll nn,ll k) { ll ans=1; ans*=_fact[nn]; ans%=mod; ans*=_inv[nn-k]; ans%=mod; ans*=_inv[k]; return ans%mod; } }; ll op(ll a,ll b) {return max(a,b);} ll e() {return -Winf; } 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 no() { cout<<"No"<<nl;} void yes() { cout<<"Yes"<<nl;} void yn(bool a) { cout<<(a ? "Yes":"No")<<nl; } #endif