結果

問題 No.3178 free sort
ユーザー Abhishek Tangod
提出日時 2025-06-13 21:53:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,884 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 202,604 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-13 21:53:14
合計ジャッジ時間 7,305 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other RE * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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);
			// divv %= mod;
		}
	}
	if(zero){
		cout << ((((n-zero)) * fac(n-1))/divv)%mod << endl;
	} else{
		cout << (fac(n)/divv)%mod << endl;
	}
	
}

int main()
{   
	IOS;

	ll t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	

    return 0;
}
0