You can use a full backpack or greedy one.
Greedy words:
(1) if it happens to be T, update the maximum hamburger count (that is, the maximum number of A + B ).
(2) If t is not collected, the maximum value of A + B is updated when T-Max is the
Description: The result of multiplying a bunch of numbers from 1 to 9 is the input value. If not, the result is-1 # include # include int main () {// freopen ("a.txt", "r", stdin); int n, x; scanf ("% d", & N); While (n --) {scanf ("% d", & X); If
We can see that the total horizontal distance is the number of collisions with the vertical side multiplied by the length of the horizontal side, that is, (a * m). Similarly, the total vertical distance is (B * n ).Therefore, the arc tangent value
Calculate the minimum number of columns that can be distinguished from all rows, use the bit vector method to generate a subset, and then enumerate the minimum subset. Note that there may be more than one space between 0 and 1. Use the char array
The simplest one in the figure, DFS ~
CodeAs follows:
# Include # include # include # include # include # include using namespace STD; char A [100 + 2] [100 + 2]; int flag [100 + 2] [100 + 2]; void DFS (int x, int y) {If (! (A [x] [Y]-
DFS ~
CodeAs follows:
# Include # include # include # include # include # include using namespace STD; char A [30 + 5] [80 + 5]; int vis [30 + 5] [80 + 5]; void DFS (int x, int y) {if (a [x] [Y] = 'X' | Vis [x] [Y] = 1) return; if (A [x]
Greedy + brute force: enumerate the locations that can be reached from near to far, and subtract the time consumed in the middle from the total time, in this way, it can be considered as a random transfer between various phishing sites (the actual
Brute force: a maximum of one hundred points. All points are brought into the equation, so that the number of points greater than zero and less than zero is the same (the number of points on both sides of the line is the same ).
At the beginning,
A complete backpack problem.
The Code is as follows:
# Include # include using namespace std; long dp [30055]; int coin [5] = {1, 5, 10, 25, 50 }; int main () {int num; dp [0] = 1; for (int I = 0; I
Divide the coin into two heaps to minimize the difference between the two heaps of coins.
0-1 backpack, which can calculate all the sum of coins, and then start to explore 0 from Sum/2 (sum is the sum of all coins, until you find the biggest coin
In the end, the greatest value of everyone is the total value.
The Code is as follows:
#include #include #include #include using namespace std;int p[1002], w[1002], mw[102], dp[32];int main(){#ifdef test freopen("input.txt", "r", stdin);#endif
Greedy. As long as there are two zeros at the beginning, you need to determine the number of consecutive zeros at the end of the last row, sort by the number of zeros at the end of the last line from large to small (because it is necessary to
String Matching: a question that is full of water, but remember that the array has to be bigger. What makes me more depressing is that it took me half an hour to wait for the question I handed in last night, I have been waiting in the queue until
Greedy + binary, minimizing the maximum value. The value of ballot box B is certain. The number of votes is divided into two parts, so that the calculated Number of ballot boxes is always B.
The Code is as follows:
# Include int City [500001];
A wonderful day begins with a water question in the early morning ~
Count the number of students with an average score or higher.
The Code is as follows:
#include#include#include#include#include#includeusing namespace std;int main(){#ifdef test
Simple simulation + DFS questions. Note that the pixel at Initialization is an uppercase letter 'O' rather than a number '0 '. In addition, ensure that x1
The Code is as follows:
#include #include #include #include #include using namespace std;int
It is actually the deformation of the range coverage. Obviously, the rectangular area covered by the circle is the length of the intersection between the circle and the total area, which converts all the circles into line segments, in this way, the
Enumeration subset + backtracking. When enumerating sub-sets, You need to perform conditional judgment in each recursive process, instead of putting them at the end of the judgment as usual.
The Code is as follows:
#include #include #include
Backtrack, enumerate the black and white situations of all vertices, and then determine the feasibility.
The Code is as follows:
#include #include #include #include #include #include using namespace std;int map[102][102], node[102], save[101], n, k,
You can trace back (note that only two adjacent elements can be exchanged ).
The Code is as follows:
# Include # include # include # include # include # include using namespace std; int a [6], B [6], cct, fct, n; void dfs (int cur, int fi)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service