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 | 3985 |
2 | jiangly | 3741 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3443 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | atcoder_official | 162 |
3 | maomao90 | 162 |
5 | adamant | 158 |
5 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
8 | djm03178 | 154 |
10 | Dominater069 | 153 |
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 |
---|