You are viewing a single comment's thread. Return to all comments →
try this out happy coding #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { string s; long long int i=0,cpl=0,n; cin>>s>>n; long long int r,q; while(s[i]!='\0') { if(s[i]=='a') { cpl++; } i++; } long long int l=s.length(); q=n/l; cpl=cpl*q; r=n%l; for(i=0;i<r;i++) { if(s[i]=='a') { cpl++; } } cout<<cpl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →