In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to solve mathematical problems in C language and simple DP knapsack problems". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Mathematics
As the name implies, mathematical problems can be solved with mathematical knowledge.
A number that cannot be bought
This is a question of the fourth Blue Bridge Cup provincial tournament JAVAC Group An and the fourth Blue Bridge Cup provincial tournament
Xiao Ming opened a candy store.
He was ingenious: he wrapped the fruit candy into a pack of four and a pack of seven.
Candies cannot be unpacked and sold.
When the children came to buy candy, he used these two kinds of packaging to combine.
Of course, there are some candies that cannot be combined, such as buying 10 candies.
You can test it with a computer. in this case of packing, the maximum quantity you can't buy is 17.
Any number greater than 17 can be combined with 4 and 7.
The requirement of this question is to find the maximum number that cannot be combined when the number of two packages is known.
Input format
Two positive integers, n _ m, denote the number of sugars in each package.
Output format
Data range
2 ≤ n,m ≤ 1000
Make sure there is a solution to the data.
Enter a sample:
4 7
Sample output:
seventeen
If you take a brief look at this question, there seems to be no rule. we can turn on the meter first to find the rules:
For (int I = 1; I > Q; cout 0) continue; if (a [I]
< 0) { ans++; flag = 1; //标记右面有蚂蚁向左走 } } for (int i = pos - 1; i >= 0; iMel -) {if (flag) / / under the premise that there are ants walking to the left on the right {if (a [I] > 0) / / if there is one on the left walking to the right, it will definitely infect ans++;} if (pre).
< 0) //首先感染的蚂蚁向左走,方法同上 { for (int i = pos - 1; i >= 0; iMel -) {if (a [I]
< 0) continue; if (a[i] >0) {ans++; flag = 1;}} for (int I = pos + 1; I
< n; i++) { if (a[i] >0) continue; if (flag) {if (a [I]
< 0) ans++; } } } cout n; for (int i = 0; i < n; i ++ ) cin >> x [I]; int left = 0, right = 0; / / indicates the number of ants walking from the left to the right, and the number of ants walking from the right to the left for (int I = 1; I)
< n; i ++ ) if (abs(x[i]) < abs(x[0]) && x[i] >0) left + +; else if (abs (x [I]) > abs (x [0]) & & x [I]
< 0) right ++ ; if (x[0] >0 & & right = = 0 | | x [0]
< 0 && left == 0) cout w[i]; for(int i = 1; i m; for (int i = 1; i >V [I] > w [I]; for (int I = 1; I = v [I]; JMub -) {f [j] = max (f [j], f [j-v [I]] + w [I]);}} cout for (int j = m; j = v [I]; JMQ -) {f [j] = max (f [j], f [j-v [I] + w [I]) }} / / if the j-layer loop is reverse: for (int I = 1; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.