Now, I am a student in a middle school. Programming is an important interest for me, and I think my programming skills are a litte poor. So could you give me some suggestions?
My English is not very good, sorry for now.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Now, I am a student in a middle school. Programming is an important interest for me, and I think my programming skills are a litte poor. So could you give me some suggestions?
My English is not very good, sorry for now.
Hello, codeforces!
Before starting to explain the topic, what I want to say is that in some of the solutions I have previously published, some highly skilled people have said that my solutions are "redundant", and they prefer to see the official solutions rather than the ones written by others. Perhaps there is a slight deviation in my understanding, but my level is indeed very limited. The solution I provided is my personal opinion, so I don't think it's unnecessary. Because my coding ability is not very high, I hope everyone can give me more encouragement, okay?
Today, I will provide the solution to question A in this competition.
This is just a easy string simulation. We just need to define a variable "flag" to determine if the different character has been found. Because the essence of a string is a character array, its minimum index is 0. So we need to add 1 to the number.
This is the AC Code:
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
cin >> s;
int n = s.length();
for(int i = 0; i < n; i++) {
bool flag = true;
for(int j = 0; j < n; j++) {
if(i != j and s[i] == s[j]) flag = false;
}
if(flag == true) cout << i + 1 << endl;
}
}
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;
}
If there are "spikes" in two or more consecutive cells, then only the quantity of all previous coins needs to be counted; If there are no consecutive $2 $or more cells with spikes, it can be proven that we can definitely reach the last cell.
So this is the code:
#include <bits/stdc++.h>
using namespace std;
int sum = 0;
int main() {
int t;
cin >> t;
while (t--) {
int n, now = 0;
string s;
cin >> n >> s;
int sum = 0;
if(s.find("**") != string::npos) {
for(int i = 0; i < s.find("**"); i++) {
if(s[i] == '@') sum++;
}
cout << sum << endl;
}
else {
for(int i = 0; i < s.length(); i++) {
if(s[i] == '@') sum++;
}
cout << sum << endl;
}
}
return 0;
}
Name |
---|