Topic PortalTest instructions: Professors give students classes, there are n themes, each subject has TI time, the class has two restrictions: 1. Each topic can only be finished in one lesson, can not be separated in a multi-class session; 2. Must be in the order of the topic, not upset. A lesson l time, if the early class, according to the amount of time, students have dissatisfaction. Ask at least a few lessons to finish the topic, if the output of a variety of scenarios with the least degree
Topic PortalTest instructions: Test instructions is difficult to understand, is a thief in M days from the city 1 flew to the city N minimum cost, entered is each city flew to other cities of the flight.Analysis: Dp[i][j] represents the thief's first day in the city J's minimum cost. State transfer equation: dp[i][j] = min (Dp[i-1][k] + cost[k][j][t%day]) T represents the cost of an aircraft flying to J on T-day KHarvest:Code:/************************************************* author:running_time
Main topic: There are n items, each item has m characteristics, each item may have or not each feature, now assume that an item, by asking certain characteristics to determine the item, ask the maximum number of times you can determine the item.Different strategies for further questioning may be taken after each inquiry, depending on the answer.With D[S][S0], the answer is S0 (that is, the item has S0 in s), at least the number of times it needs to be asked. Enumerates the feature completion rec
I wrote the code myself.#include #include using namespace Std;int main (){int N,a[100],b[100],q,flag;int k=1;while (CIN>>N>>Q){for (int i=0;i{cin>>a[i];}for (int j=0;j{cin>>b[j];}Sort (a,a+n);for (int j=0;j{flag=0;coutfor (int i=0;i{if (A[i]==b[j]){coutflag=1;Break}}if (flag==0){cout}}}return 0;}The code written on the book#include #include using namespace Std;int main (){int n,a[100],q,x;int k=1;while (CINGT;GT;NGT;GT;Q){for (int i=0;i{cin>>a[i];}Sort (a,a+n);coutwhile (q--){cin>>x;int P=lower_
Test instructions: Given a string, it can be divided into several palindrome strings at least.Analysis: Dp[i] means that the first I characters can be divided into several palindrome, dp[i] = min{1 + dp[j-1] | J-i is a palindrome}.The code is as follows:#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include UVa 11584 Partitioning by palindromes (simple DP)
Path Recording method: If DP[J-VALUE[I]]+VALUE[I]>DP[J] Description took this thing, the mark is 1,For loop flag, found to be 1, printed out, and the capacity of the backpack to reduce, and then in the secondary capacity to look for signs;#include #include#includeusing namespacestd;intvalue[ -],dp[10001],s[ -][10001];intMain () {intn,m; while(cin>>m) {cin>>N; for(intI=1; i) Cin>>Value[i]; Memset (DP,0,sizeof(DP)); memset (s),0,sizeof(s)); for(intI=1; i) for(intj=m;j>=value[i];j--)
Title: PortalTest instructions: To find the number of n greatest common divisor, violence will not time out, the difficulty in no number control input.Solution: Enter it in a special way.#include #include#include#includeusing namespacestd;intgcdintAintb) { if(b==0)returnA; returnGCD (b,a%b);}intMain () {intT; CIN>>T; GetChar (); while(t--) { CharC; intdata[ the],cnt=0; while((C=getchar ())! ='\ n') { if(c>='0'c'9') {ungetc (C,stdin);//returns the character C t
Test instructions: A circle of land, select n points in the circumference, and then 22 lines, ask how many pieces of this piece of land into?Analysis: This problem uses Euler formula, in the plan, v-e+f=2, where V is the number of vertices, E is the number of edges, F is the number of polygons. For this problem, just calculate V and e as well.We enumerate the diagonal from a vertex, the line to the left of the I point, then the right side of the n-i-2 point, then the two sides of the lines on th
);//the lower left corner of the building must be seen for(intI=1; i){ BOOLvis=false; for(intj=0; j1; j + +){ if(B[i].x+b[i].w Break;//Add this sentence, simplify the program, when the right side of the b[i] building is less than x[j] when the point is definitely not visible if(Visible (I, (x[j]+x[j+1])/2)){//true B[i] visible at the midpoint between the left and right bordersvis=true; Break; } } if(Vis) printf ("%d", b
Test instructions: Give a string consisting of a number, and then add three operation symbols * + in the string, which requires the output of all added operators and the result equals 2000 after the operation. All numbers cannot have a leading 0,And the formula must be legal.Analysis: The problem is very obvious violence, because the longest only 9 digits, that is, a maximum of 8 positions may be inserted in the symbol, of course, there is not so much, so the direct violence on the line, do not
Test instructions: C (p,q)/C (r,s), 4 numbers are less than 10000, the answer is not greater than 10^8Idea: According to the scope of the answer guess, do not need to use high precision. According to the unique decomposition theorem, each number can be decomposed into a number of primes multiplied. First, all the primes within 10000 are calculated, and the exponent of each molecule part is calculated by using a array to represent the index of the prime number in the unique decomposition formula,
and directions of The n ants in the same format and order as in the input. If the or moreants is at the same location, print "Turning" instead of "L" or "R" fortheir direction. If the ant falls off the pole before T seconds,print "Fell off" for that Ant. Print an empty line after each test case.
Sample Input
Sample Output
1 R5 R3 L10 R10 2 R5 L8 R
Case #1:2 Turning6 R2 Turningfell offcase #2:3 L6 R10 R
This question is really not simple
= the;8 9 structbuilding{Ten intID; One Doublex, Y, W, D, H; A BOOL operatorConstbuilding RHS)Const{ - returnX //Overloading - } the }B[MAXN]; - - intN; - Doublex[2*MAXN]; + - BOOLSolveintIDoublemi) + { A if(! (B[i].xreturn false;//returns False when the midpoint is not in the building B[i] range at for(intK =0; K ) - { - if(b[k].yreturn false; - //returns False if there is a building in front of the building and the height is greater than
]}\)\ (\text{equals complete)}\)\ (\text{+1}\ )
\ (\text{(Focus!!) }\)\ (\text{here is an important tip: Enumerate}\)\ (\mathcal{s}\)\ (\text{subset}\)\ (\mathcal{s0}\) .
See the following code:f[0]=0;int All=(1How to analyze the time complexity of the above algorithm? \ (qwq\)? It is equal to the sum of subsets of all subsets of the complete \ (\mathcal{(,..., N)}\) , which can also make\ (\mathcal{c (S)}\) represents the number of subsets of set S (it equals \ (\text{2}\)\ (\mathca
Test instructions: Given a number n, the number of triangles can be formed by arbitrarily selecting 3 numbers from the 1-n.Analysis: Dp[i] indicates that the number of triangles can be formed by arbitrarily picking out 3 numbers from a 1-i.The code is as follows:#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include UVa 11401 Triangle counting (count DP)
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.