Give the length and width (or width and length) of the 6 rectangles, and ask whether the six rectangles can form a box.The idea is relatively simple, but there are a lot of places to pay attention to.First, because of the length and width of the order, so to deal with (at first only to deal with the later reading of the five groups, no processing of the first group read separately, bad reviews)Then decide if you can divide into 22 identical three groups.If able, enumerate 8 possible equal cases.
Test instructions: You n team to play, every two teams to play 2 games, win 3 points, flat 1 points, lose 0 points, after the game to select a Dream team, the number of goals required to score the most, the largest number of wins, the fewest number of missed goals, and three can not be compared with the other column first. Ask about the lowest possible ranking of the Dream team.Analysis: its real 3 limit conditions only the number of victories is most useful, because the dream team can win the
The main idea: There are eight digital three-way, to find the minimum number of rotations so that the number of graphs in the middle eight. Rotation rule: For each long row or column, each rotation is to move the data to the position of the head, and the number on the head is placed at the tail. If the number of times is the same, the minimum rotation order of dictionary order is found.Title Analysis: ida*, if currently in the CUR layer, the number of the middle eight number of three-in-one is a
Very naked a Dijk algorithm problem, because the vertex number is too many can not be represented by the adjacency matrix, so the critical table is used to representAC Code#include #includestring.h>#include#include#include#includeusing namespacestd;using namespacestd;Const intmaxn=2*50000;#defineINF 99999999structnode{intv; intu; intW; intNext;} V[MAXN];intHEAD[MAXN];intD[MAXN];intn,m,s,t;intTol;intDone[maxn];typedef pairint,int>PII; priority_queueQ;voidinit () {tol=0; memset (Head,-1,sizeof(hea
The main idea: an undirected graph, a robot, a number of stones, each move can only move to the connected node, and only one node can have the same and one thing (robot or stone), to find a robot from the specified position to another specified position of the minimum number of steps, the output move step.Analysis of the problem: the position of the robot and the location of the stone to mark the status of the state, the number of States has a maximum of 15*2^15. Wide search of the.The code is a
line.Note:the sample instance and an optimal solution are shown in the? Gure below. Items are numberedFrom 1 to according to the input order.Sample Input1108070153035108020351030Sample Output6Test instructionsGiven the weight of N (nExercisesThe number of our two-pack backpackCheck the time first arrogant to small fill one in each backpackFill it up from big to small, and check if it's done.And just pay attention to the output format.#include #include#include#include#includeusing namespacestd;C
Test instructionsEnter n number, number I ai satisfies 1≤ai≤i. Adds a symbol to each number, and the value is 0.Analysis:Starting with the largest element (assuming K), the SUM/2 can be sorted out. With the removal of the set of K, it will be possible to make up SUM/2-a[k]. As long as sum is even, there must be a solution.Code: #include #include #include #include using namespace Std;const int maxn=1e6+5;int A[MAXN];int R[MAXN];BOOL CMP (int x,int y){return a[x] }int main (){int n;int i;while (~
Title: Give you a n*n form, two people take turns to operate, each time in a position to put or win a pawn;If a state, before it appears, then the other wins, ask who wins, if no one wins, output draw.Analysis: DS, data structure, hash function, state compression.Each row is stored in a single bit, a one-dimensional array represents a state, and a hash table is used to store the lookup.Description: Note that the rotated State is considered to be the same.#include
The main idea: to cut a wooden stick that is long as l at a given n cutting point, the cost per cut is equal to the length of the current stick. The minimum cost to cut into n+1 segments.Topic Analysis: Interval DP. The definition of DP (I,J) represents the cost of the cut interval i~j, then f (i,j) =min (f (i,k) +f (k,j)) +dist (I,J). The complexity of time is N3.The code is as follows:# include UVA-10003 Cutting Sticks (interval DP)
can not confirm the quantity maximum, the time is how much, so to initialize the DP to judge by a special value, namely the complete backpack;In this way, the time of the greatest number of times is guaranteed to be the total time spent;Links: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34887#include#include#include#include#include#include#include#include#includeusingnamespacestd;intdp[10000];constintinf=0x3f3f3f3f;intnext[55];inta[55],t,n;intmain(){intT,cas=1;cin>>T;while(T--){
Title: There are 4 positions, each moving from one position to another requires a specific cost, the minimum cost of a sequence of specified sequences. Only one foot at a time can move, or move and step down.Use D[i][j][u] to indicate that the first I position is complete and the minimum cost in the state (J,u), (J,u) One of which must be equal to A[i], assuming J and A[i] are equal, then either the previous state is (j,u), or the previous state is (k,u), note that the previous state cannot be (
The main topic: N Records, each with a length and frequency, the problem requires the lowest formula value. For a sort, output the ID of the CD under this sort.Idea: greedy, the longer the length of the back, the lower the frequency to put more behind, so press len/p to sort.#include #include #include #include using namespace Std;struct CD{int id;Double Len;Double p;} cd[100000];int CMP (CD A, CD B){return A.LEN/A.P }int main (){int n,m;while (~SCANF ("%d", n)){for (int i = 0; i scanf ("%d%lf%lf
The main topic: n the absolute value of the different non-0 integers, select as many as possible, into a sequence, so that the positive and negative numbers alternating and absolute value increment.Analysis: Order by absolute size, then scan once, by the way, make a mark.#include #include #include using namespace Std;int cmp (int a,int b){Return ABS (a) }int main (){int cas,a[100000],n;scanf ("%d", cas);for (int ii=1;ii{scanf ("%d", n);for (int i=1;iscanf ("%d", a[i]);Sort (a+1,a+1+n,cmp);int fl
shape, requiring the smallest perimeter, where a, b two point coordinates are given, and the c,d point is required on the x, Y axis positive half axis.Analysis: Symmetric point connection with X, Y axis. Proof very well, the shortest line between two points.1#include 2#include 3#include 4#include 5 #defineError 1e-86 using namespacestd;7 Const intMAXN =10010;8 9 Ten DoubleGet_len (DoubleX1,DoubleY1,DoubleX2,Doubley2) One { A returnsqrt ((y2-y1) * (y2-y1) + (x2-x1) * (x2-x1)); - } - intMain
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.