You are viewing a single comment's thread. Return to all comments →
A better way to write...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string s; cin >> s; long n; cin >> n; auto repetition = n / s.size(); auto partial = n % s.size(); auto aCountInString = count(begin(s), end(s), 'a'); auto aCountInPartial = count(begin(s), begin(s) + partial, 'a'); cout << aCountInString * repetition + aCountInPartial; 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 →
A better way to write...