結果
問題 |
No.3178 free sort
|
ユーザー |
|
提出日時 | 2025-06-13 21:49:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,853 bytes |
コンパイル時間 | 1,727 ms |
コンパイル使用メモリ | 202,712 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-13 21:49:41 |
合計ジャッジ時間 | 7,250 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | RE * 40 |
ソースコード
// #undef _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; #define mod 998244353 #define gcd(a,b) __gcd(a,b) #define lcm(a,b) a/gcd(a,b)*b // no overflow #define bits(x) __builtin_popcountll(x) #define endl "\n" #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); typedef long long int ll; string to_string(const string &s){ return "{" + s + "}"; } string to_string(const char &c){ string s = ""; s += c; return s; } template <typename A, typename B> string to_string(const pair<A, B> &p){ return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A, typename B, typename C> string to_string(const tuple<A, B, C> &t){ return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")"; } template <typename A> string to_string(A v){ string res = "{"; bool f = 0; for(const auto &u: v){ if(f){ res += ", "; } f = 1; res += to_string(u); } res += "}"; return res; } void cus_debug() { cerr << "]" << endl; } template <typename Head, typename... Tail> void cus_debug(Head H, Tail... T) { cerr << to_string(H) << ", "; cus_debug(T...); } #ifdef _GLIBCXX_DEBUG #define debug(x...) cerr << "[" << #x << "]:[", cus_debug(x) #else #define debug(...) 42 #endif unordered_map<ll, ll> mp; ll fac(ll n){ if(n == 0)return 1; // return (n%mod * fac(n-1)%mod)%mod; return (n * fac(n-1)); } ll divv = 1; // start of CP 2.0 void solve(){ string s; cin >> s; ll n = s.size(), zero = 0; for(auto u: s){ if(u == '0'){ zero++; } else{ mp[u-'0']++; } } for(auto u: mp){ if(u.second>1){ divv = divv * fac(u.second); } } if(zero){ cout << ((n-zero) * fac(n-1))/divv << endl; } else{ cout << (fac(n)/divv)%mod << endl; } } int main() { IOS; ll t=1; // cin>>t; while(t--){ solve(); } return 0; }