optimize_ofast's blog

By optimize_ofast, history, 5 months ago, In English

This question is quite easy!

We only need to input t sets of data and traverse each string. And use two counters, "suma" and "sumb", to determine the number of occurrences of letter A and letter B, and compare them.

It is worth noting that the title has already mentioned that the length of the string is 5, so we do not need to determine whether suma is equal to sumb.

Hope to see your comments!

Below is the AC code:

#include <bits/stdc++.h>
using namespace std;

int t;
int main() {
	cin >> t;
	while(t--) {
		string s;
		cin >> s;
		int suma = 0, sumb = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s[i] == 'A') suma++;
			else sumb++;
		}
		if(suma > sumb) cout << "A" << endl;
		else cout << "B" << endl;
	}
	return 0;
}
  • Vote: I like it
  • -5
  • Vote: I do not like it

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think some of the problems of "Codeforces Round Div.4" are a little difficult to me.

What should I do?

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    so for you its better to switch on codechef.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

yes but who asked

»
5 months ago, # |
  Vote: I like it +21 Vote: I do not like it

I mean your effort is fine, but people don't really need extra blog editorial for these simple problems, they'd just look fot the official ones right?

Publish editorial only when it's official editorial is not published or you have something really unique to add. Don't add editorial for very simple problems either.