left or right interval, and then another two points.The difference between three points and two points The dichotomy method is suitable for monotone functions, and the single-peak function with two points is obviously not very good, for some of the mono-peak function, can be converted to a monotone function, thus using two points, but many cases of derivation is very troublesome, then need to use three points.const int Inf=0x3f3f3f3f;int n;double x,y,c1,c2,sum,ans;const double eps=1e-8;double d
]=dist[x]+Temp.weight; the Que.push (to); - } - } the } the } the intx=0; the for(intI=1; i) -x=Max (x,dist[i]); the returnx; the } the intMain ()94 { the //Read (); the intt,a,b; thescanf"%d",t);98 while(t--) About { -scanf"%d%d",n,m);101 for(intI=1; i) adjmap[i].clear ();102 for(intI=1; i)103 {104scanf"%d%d",a,b); theAdjmap[a].push_back (Edge (b,1));106Adjmap[b].push_back (Edge (A,1));107 }1
1204:rectangles Time limit:1 Sec Memory limit:128 MB
submit:732 solved:104
[Submit] [Status] [Web Board]
DescriptionIf the edge length of the bounding rectangle must be an integer and the perimeter is a constant l, how many different rectangles are in the [A, B] range?In this problem, when and only if two rectangular areas are not the same, the view is two different rectangles.InputThe first line of the input data contains an integer t (1 For each set of test data, contains three integ
Output5-----------------------------------trie, the array does not have to open to 1e6, the title guarantee there will be no extreme case (i mle, hehe)---------------------------------------------------------------------------------------------#include using namespace std;Const int N(5e5+5);struct node{int ID, DEP, nt[ -];void Init(int _id, int _DEP) {ID=_id, DEP=_DEP, memset (NT, 0, sizeof(NT));}void Renew() {ID=0;}}trie[n];Char S[n];BOOL vis[1005];void Build_trie(int N) {int tot=0;Trie[tot].i
Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1265DescriptionAn example of a traditional dice are a rounded cube with each of its six faces showing a different number of dots from 1 t o 6. When thrown or rolled, the dice comes to rest showing on its upper surface a random integral points from one to six, each Value being equally likely.----WikipediaNow we have a dices which both with six faces. Can you tell us the probability, the sum points of the dices equals S when we thrown?In
. (7) print a: a a you need to do this in turn N operation, and when encountering the first (7) class operation, the value of the variable is output as required. Input The first line of the input data contains an integer n (1 N operations. Then there are N row, each row contains a shape as described above. Output (7) class operation, output an integer in one line representing the value of the variable. The data guarantees that the value of each variable is not e
empty (because the letter' A ', ' P ', ' M 'Morse code is not enough.5bits, so only the first few lines represent its Morse code, the rest of the action is empty). Now all you have to do is print out the light and dark of the dot on the dial for a given time.InputEnter the first behavior of an integer T (1 , which means that there are next T Group test Data. one row for each set of test data, containing three lengths of2string, separated by a space in the middle. The first string is a onto the
Click to open linkLine tree new function get, it's amazing. @[email protected]Go through the tree first, the time stamp records the time before and afterThe pre-and post-time of the child node will be within the parent node's time rangeMaintaining the minimum depth and depth of the interval with the segment tree#include "Segment Tree" CSU 1414 Query on a tree
Topic Connection: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333Test instructions: give you an n vertex, M edge (each edge has three parameters, opening time, closing time, and the time of passing this edge) of the direction graph;You need to find the shortest path from S to T; Dijkstra algorithm can be solved;Pit point: I use the queue optimization +vector store each edge, after each call Dijkstra, must initialize the adjacency table, in this place for a long time, this is the second, af
Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1409Descriptiongive two sets consisting of integersA,B, calculateA∪Bcontains the number of integers. Inputthe first line of input contains an integerT(T> 0), indicating that there are altogetherTGroup test Data. for each set of test data, the first row contains an integerN(1≤N≤Ten5). The second line contains 2Nan integera1,b1,a2,b2,...,aN,bN(0 a1≤b1a2≤b2aN≤bN9), indicatingA=[a1,b1]∪[a2,b2]∪...∪[aN,bN]. The third line contains an intege
title Link:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1408Descriptionas shown, we planted a straight road in front of the door.Ntrees. However, recently we have found that if the distance between two saplings is less than a constantD, the development of the two saplings will be hindered. So we decided to remove some saplings so that the distance between any two saplings is not less thanD, and the more saplings we wish to leave, the better. Inputthe first line of input contains an integerT(
Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505DescriptionEnter some words that consist only of lowercase letters. Your task is to count how many words are "cool", that is, each letter appears in a different number of times.Ada is cool, for example, because a appears 2 times, D appears 1 times, and 1 and 2 are different. For example, banana is also cool, because a appears 3 times, N appears 2 times, B appears 1 times. However, BBACCCD is not cool because A and d appear the same
Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511DescriptionInputThe input contains no more than 10000 sets of data. Each set of data contains 6 integers r1, C1, R2, C2, R3, C3 (1OutputFor each set of data, the test point number and the minimum number of steps are output.Sample Input1 1 8 7 5 61 1 3 3 2 2Sample OutputCase 1:7case 2:3HINTSourceThe tenth session of Hunan Province College students computer Program design ContestThe code is as follows:#include
Prime slotDescription In the adjacent two primes p p + n the n- 1 n 24, +, +,- is in prime number 23 29 A length of 6 Your task is to write a program to calculate The length of the prime slot that contains the integer k. If K itself is a prime number, it is assumed that the length of the prime slot containing K is 0. InputThe first line is a number N that represents the number of data that needs to be tested. Followed by n rows, each line being a positive integer k,k
Test Instructions:There are three families with a garden, and the wives of each family are required to help arrange the garden. Mrs. A worked for 5 days, and Mrs. B worked for 4 days before finishing the garden. Mrs. C was 90 yuan because she was pregnant unable to join them. How is this money assigned to a and B two wives more appropriate? How many dollars does A deserve? 90/(5+4) *5=$50 yuan? If you think so, you'll be fooled! The correct answer is 60 yuan. If you don't get it, think again. He
1333:funny Car Racing Time
limit: 1 Sec
Memory Limit: MB
Submit: 482
Solved: 116
[Submit] [Status] [Web Board]
DescriptionThere is a funny car racing in a city with N junctions and m directed roads.The funny part Is:each Road is open and closed periodically. Each road was associate with a integers (a, b), that means the road would be an open for a seconds , then closed for b seconds and then open for a seconds ... All these start from the beginning of the race. You mus
Topic Link: Click to open the linkGiven n individuals, the vehicle's manned capacity mThe A[i] array is given belowIf you want to invite me to the car, you must first invite A[i]Q: How many people can I invite?It is observed that this is a forward graph, and the resulting graph is similar to the tree, but the tail of the chain is a simple ring, according to I->a[i.As follows:5 22 3 4 1 4We must first invite 1234 at the same time to invite 5.So create a reverse graph (that is, the opposite side),
DescriptionSunnypig is a pig who is much cleverer than any other pigs in the pigpen. One sunny morning, Sunnypig wants to go out of the pigpen to date Mrs Snail, he beloved. However, it's terribly tough for a pig to go out of the the Pigpen because the pigpen are divided into M * N grids with fences Which pigs cannot go across. Luckily, there is some doors unlocked on the fences so this sunnypig can push them open with his nose. Since Sunnypig was a pig, no matter how clever he was, he can never
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.