https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Codeforces-Round-411-Div-2-problem-D-Minimum-number-of-steps-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #411 (Div. 2), problem: (D) Minimum number of steps Solution In C/C++

#include<bits/stdc++.h>
using namespace std;
int c,d,i,n,m,k,x,j=1000000007;
string s;
main(){
cin>>s;
for(i=s.size()-1;i>=0;i–){
if(s[i]==’b’)c++;else{
k+=c;c*=2;k%=j;c%=j;
}
}
cout<<k;
}

(Visited 22 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: