"%i64d%i64d", h, n); -n + = sum[h-1];//into the number in the whole binary tree. -LL x =N; +Anc1.push_back (x);//all ancestors of the target node - while(X! =1) + { AX/=2; at anc1.push_back (x); - } - //for (int i = 0; i - -LL node =1; - BOOLChoice =false;//traverse the line of defense (L or R) in - while(Node! =N) to { +Vector//ancestor of the current leaf node x - for(inti =0; I i) the { * anc2.push_
what Gerald's hexagon looks like in the first sample:And that's what's it looks like in the second sample:The main topic: Known hexagon six side length, the number of units to be three equilateral angle. The side length is given in a clockwise order, in units of the triangle edge lengthMake a hexagon into a big equilateral triangleFinding triangles is easierSubtract 3 small triangles from a large triangle#include using namespacestd;intMain () {intx[6]; while(cin>>x[0]>>x[1]>>x[
increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.InputThe First line of the input contains an integer n (5 )-the size of ArrayThe second line contains n distinct space-separated integers: a[1],? A[2],?...,? a [N] (1?≤? ) A[i]?≤?109).OutputPrint "Yes" or "no" (without quotes), depending on the answer.If your answer is 'Yes', then also print of space-separated integers denoting start
integersRAndG, Separated by a single space-the number of available red and green blocks respectively (0? ≤?R,?G? ≤? 2 · 105,R? +?G? ≥? 1 ).Output
Output The only integer-the number of different possible Red-Green towers of heightHModulo 109? +? 7.Sample test (s) Input
4 6Output
2Input
9 7Output
6Input
1 1Output
2Note
The image in the problem statement shows all possible Red-Green towers for the first sample.
Analysis: DP, calculate the height, and th
connecting both shops.
OutputPrint the minimum distance that Patrick would has to walk in order to visit both shops and return to his house.Sample Test (s)input10 20 30Output60input1 1 5Output4NoteThe first sample is shown on the problem statement. One of the optimal routes Is:house first shop second.In the second, sample one of the optimal routes Is:house first shop house second.Test Instructions : let you go from the middle of the house after a A, a, and back to the original point, the m
[i]; the the for(j=1; j -; j + +) About { theChange1,0N0); the for(i=0; i) the if(str[i]- thej) +Change1, i,i+1,1); - for(i=1; i) the {BayiTmp=query (1, l[i]-1, R[i]); theChange1, l[i]-1, R[i],0); the if(TMP) - { - if(typ[i]==0) theChange1, R[i]-tmp,r[i],1); the Else theChange1, l[i]-1, l[i]-1+tmp,1); the } - } the the for(i=1; i) the if(Query (1, I-1, i)
is:After the first visit of cells (2,?2) the ice on it cracks and when you step there for the second time, your Chara Cter falls through the ice as intended.Test instructions: The map of N*m, ' X ' represents a cracked ice, '. ' Represents the complete ice, the cracked ice will be broken once again, the complete ice will be trampled to become a cracked ice, now tell the starting point and the end, ask whet
Lucky, this time CF Rose, incredibly is the room second (but if the D problem tle, on the first)Use String to Tle, add subscript with char, and see more bull algorithm,1#include 2#include 3#include 4 using namespacestd;5 Const intmaxx=200010;6 CharA[maxx],b[maxx];7 BOOLcmpintP1,intP2,intlen)8 {9 for(intI=0; i)Ten if(A[I+P1]!=B[I+P2])return 0; One return 1; A } - BOOLJudgeintP1,intP2,intlen) - { the BOOLflag=CMP (P1,p2,len); -
Test instructions: Bishop on the same diagonal (that's right. =) will attack each other and seek the logarithm of each other.Since there are positive and negative diagonal lines, the X-y and x+y written by each bishop are saved with two arrays respectively.And then scan each array for the repeating number k ans plus kC2 on the line.WA took two rounds because it didn't take into account that if the entire array was duplicated, the last amount was added once.#include #include#include#include#inclu
Gena choose new numbers s and before every match. Besides, for the sake of history they keep a record of each match:that are, for each serve they write down the winner. Serve winners is recorded in the chronological order. In a record the set was over as soon as one of the players Scores t points and the MA TCH is over as soon as one of the players Wins s sets. Petya and Gena has found a record of an old match. Unfortunately, the sequence of serves in the record isn ' t divided to set
ATest instructions: Gives N,f (n) =-1+2-3+4-5+----+ ( -1) ^n*n, calculates the value of nDirectly according to the formula calculation, at the beginning of the Doubi, directly to calculate, then the group can be counted.N is an odd time, there are N/2 1 plus the last-nWhen n is an even number, only N/21#include 2#include 3#include 4#include 5 using namespacestd;6
Test instructions: give you a n*m character matrix, ask you to walk from (to n,m) How many methods are passed by the string is a palindrome, can only go right or downDP[][I][J] I J stands for the two points that are currently going to the horizontal axis so that (i,y1) (n,m)--(J,Y2) Get the same number of methods#include using namespacestd;Const Long LongMoD = 1e9 +7;Charp[510][510];Long Longdp[2][510][510];intdir[4][
help him and determine this minimum number of flats he have to visit. Input
The first line contains the integer n (1≤n≤100)-the number of flats in the house.
The second line contains the row s with the length n, it consists of uppercase and lowercase letters of 中文版 alphabet, The i-th letter equals the type of Pokemon, which was in the flat number I. Output
Print the minimum number of flats which Sergei B. should visit in order to catch pokemons of all types which there is in The house. Examples
"Interesting integer" exercises, Interview Questions (Article 2), and exercises (Article 2)
Link 1: "interesting integer" exercises and interview questions (Article 1)
6 questions: number of replies
When a multi-digit reads by bit, the result is the same whether it is read from left to right or from right to left. For example, 11, 22, 101, etc. Write a program to obtain the prime number of the reply and th
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.