This is the first time I've played Codforce.
- Question A and Question B and Question C just have ideas, but they are not written out. As for D E F, there is no desire to see that there may be no challenges. Even if you can't do it later, you will think about ideas.
- To sum up, it's still not thorough understanding of the algorithm, not enough thinking to do the problem, not enough open-minded.
- And I always want to use a snake to add to my feet when I have mastered that algorithm.
- Looking at other people's code really feels the charm of the algorithm is simple and generous.
- After reviewing quickly, you can write a code for winter vacation happily.
Let's start with the title.
A
- Question Description: Essentially, we take the sugar problem with three or seven given candies at a time to find out if we can get the candy successfully.
My own writing dfs
#include<iostream>
using namespace std;
void dfs(int ans,int a);
int step[] = { 3,7 };
bool flag;
int main()
{
int T;
int a;
cin >> T;
while(T--)
{
cin >> a;
flag = false;
dfs(0, a);
if (flag == true)
cout << "YES" << endl;
else
cout << "NO" <<endl;
}
}
void dfs(int ans, int a)
{
int i;
int dans;
for (i = 0; i < 2; i++)
{
dans = step[i]+ans;
if (dans < a)
dfs(dans, a);
if(dans==a)
{
flag = true;
return;
}
if (dans > a)
return;
}
}
The Writing of the Great God
int main() {
int n, a;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a;
bool flag = 0;
for (int j = 0; j < a && j * 3 <= a; ++j) {
for (int z = 0; z < a && j * 3 + z * 7 <= a; ++z) {
if (j * 3 + z * 7 == a) {
cout << "YES\n";
flag = 1;
break;
}
}
if (flag) break;
}
if (!flag) cout << "NO\n";
}
}
- Because the amount of data is not very large, so direct violent search is good. If the situation is not too many, violent solution is ok.
B
- Question Description: Upgrade and Output Process
- My own idea: the first thing I think about is bfs and then I won't write it later... The process of output is like this. There's no way to think about it.
The Writing of the Great God
I think it's the simplest, simplest and most effective way.
#include <bits/stdc++.h>
using namespace std;
int main() {
int h1, a1, c1, h2, a2, cnt = 0;
cin >> h1 >> a1 >> c1 >> h2 >> a2;
vector<string> ans;
while (h2 > 0) {
if (a2 < h1 || h2 - a1 <= 0) {
ans.push_back("STRIKE");
h2 -= a1;
h1 -= a2;
}
else {
ans.push_back("HEAL");
h1 += c1;
h1 -= a2;
}
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); ++i)
cout << ans[i] << '\n';
}
- This problem should not have been solved.
C
- Problem Description: The problem of placing boxes requires that boxes be discharged according to size and that boxes with boxes in them cannot continue to be placed.
- My own idea: At first, greedy method is similar to the problem of finding the least overhead by cutting boards, that is to say, the two smallest numbers must be the same series of trees and then divided into a layer and so on.
The Writing of the Great God
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a;
cin >> n;
map<int, int> c;
for (int i = 0; i < n; ++i) {
cin >> a;
c[a]++;
}
int sol = 0;
for (auto p : c) {
sol = max(sol, p.second);
}
cout << sol << '\n';
}
emmmm I don't understand...
So wait till you have time to fill in the pit of this competition, or wait till I get stronger to fill in the pit (nonexistent)