Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- ll int MOD = 998244353;
- int N = 2e5 + 100;
- vector<ll int> fact(N);
- fact[0] = fact[1] = 1;
- for(int i=2; i<N; i++)
- (fact[i] = i*fact[i-1]) %= MOD;
- _test
- {
- string s;
- cin>>s;
- int n = s.size();
- ll int cnt = 1;
- ll int ans = 1;
- int x = 1;
- char f = s[0];
- for(int i=1; i<n; i++)
- {
- if(f != s[i])
- {
- (ans *= cnt) %= MOD;
- x++;
- cnt = 1;
- }
- else
- cnt++;
- f = s[i];
- }
- (ans *= cnt) %= MOD;
- (ans *= fact[n-x]) %= MOD;
- cout<<n-x<<" "<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement