如题。
代码:
#include <bits/stdc++.h>
using namespace std;
#define mod 99824353
char s[1000050];
int n , m , l , r;
int main() {
cin >> s;
cin >> m;
int len = strlen(s);
long long ans1 = 0 , ans2 = 0 , ans3 = 1;
for( int i = 0 ; i < len ; i++ ) {
if( s[i] == '1' ) ans1++;
ans2 = ans2 + s[i] - '0' % mod;
ans3 = ans3 * ( s[i] - '0' ) % mod;
}
while( m-- ) {
cin >> l >> r;
char ch[10050];
cin >> ch;
for( int i = l - 1 ; i < r ; i++ ){
if( s[i] == '1' ) ans1 = ans1 - 1 % mod;
ans2 = ans2 % mod - ( s[i] - '0' ) % mod;
ans3 = ans3 / ( s[i] - '0' );
}
for( int i = 0 ; i < strlen(ch) ; i++ ) {
if( ch[i] == '1' ) ans1++;
ans2 = ans2 + ch[i] - '0' % mod;
ans3 = ans3 * ( ch[i] - '0' ) % mod;
}
cout << ans1 % mod << " " << ans2 % mod << " " << ans3 % mod << endl;
for( int i = l - 1 , j = 0 ; i < r ; i++ , j++ )
s[i] = ch[j];
}
return 0;
}