) - { inmemset (D,0,sizeof(d));//Array Clear 0 - for(i =1; I ) to { +fa[i]=i; - } thescanf"%d",m); * for(i =0; I ) $ {Panax Notoginsengscanf"%d%d",a,b); -d[a]++; thed[b]++;//record the degree of each point + F1 (A, b); A } theCnt=0; key=0; + for(i =1; i) - { $ if(D[i]%2)//To judge that each point is an even degree $ { -key=1; - } the if(i = = Fa[i])//Judging there's no indepen
inputs. Output "Yes" If Harry can finish his homework, otherwise output "No."(Do not ignore the period)Sample Inputsosoonrivergoesthemgotmoonbeginbig0 Sample Outputyes. Harry can read this mantra: "Big-got-them."#include #include#include#includestring.h>using namespacestd;BOOLvis[ +];Charstr[ +][ +]; BOOLBFsintN) {Queueint>que; intA, Len; for(inti =0; I //first, the first letter is a b queue. { if(str[i][0] =='b') {Que.push (i); Vis[i]=true;//indicates that the word has been marked.
1#include 2 intMain ()3 {4 inta[ -],n,i,t,k;5 while(~SCANF ("%d", n) N)6 {7 for(i=k=0; ii)8 {9scanf"%d",a[i]);Ten if(A[i]//looking for the minimum value position Onek=i; A } - if(k)//not the first one, then the first exchange. - { thet=a[0]; -a[0]=A[k]; -a[k]=T; - } + for(i=0; ii) - if(i)//Control output Format +printf"%d", A[i]); A Else atprintf"%d", A[i]); -printf"\ n"); - } - ret
files and C + + input and output header files.Function Two:Char *strtok (char s[], const char *d); This is the prototype, which decomposes the string into a set of strings. The string that s wants to break down. D is a delimiter character because all D is substituted for the first execution of this function, so you need to change s to NULL when you call it again (the C language takes it as the last character of the string to represent the end of the string. ") ").Function Three:Atoi () (represe
The 1004 question is actually very simple, is wants you to count the most balloons the number, but in the output time but needs to be careful carefully, conforms to the question request.In the output is the first note is the output order: If there are multiple numbers of the same color, first input first output, such as,RedGreenRedGreenThis situation requires an outputRedGreenPost the AC code:#include Hangzhou Electric OJ 1004 realization and some t
means that all the time is converted into smaller units (that is, multiplied by 11), which avoids the problem of precision.See the code for details:1#include 2 intMain ()3 {4 inth,m,s,a,da,tots= A*3600* One, kase=1;5 while(SCANF ("%d:%d:%d", h,m,s) = =3)6 {7 intTar = One* (h*3600+m* -+s);8scanf"%d",a);9Da = the-2*A;Ten intCNT = A * -, F =1; One //The position at the beginning is a° (obviously the first minute is the second hand in front) . A while(c
descriptiongiving N integers, V1, V2,,,, Vn, you should find the biggest value of F.Inputeach test case contains a single integer N (11#include 2#include 3 using namespacestd;4 inta[100000];5 intMain ()6 {7 __int64 n,j;8 while(SCANF ("%i64d", n) N)9 {Ten for(__int64 i=0; i) One { Ascanf"%d",a[i]); - } -Sort (a,a+n); thej=a[n-1]*( .-n); - for(__int64 i=1; i ) -j=j+a[n-1-i]; -printf"%i64d\n", j); + } -}Hangzhou El
Descriptiona range is given, the begin and the end are both integers.You should sum the cube of all the integers in the range. Inputthe first line of the input was T (1 Each case of input is a pair of integer A, a (0 1#include 2__int64 a[1000000]={0,1};3 intMain ()4 {5 for(__int64 i=1; i1000000; i++)6 {7a[i]=a[i-1]+i*i*i;8 }9__int64 t,k=0;;Tenscanf"%i64d",t); One while(t--) A { - __int64 m,n; -scanf"%i64d%i64d",m,n); theprintf"Case #%i64d:%i64d\n", ++k,a[n]-a[m-1]); - }
. Then a long time to think about the reason, finally after I Baidu to know where the problem.When n (n+1) is multiplied, it overflows. The title asks "may assume the result is in the range of 32-bit signed integer", which requires that the sum is a 32-bit signed integer. The sum of the test data given by OJ (n (n+1)/2) must be within the range of 32-bit integers, but (n (n+1)) is not necessarily. The reason you can infer WA should be here. You can subtly change the formula:Putsum=n* (n+1)/2;Swi
Problem Description There is many lamps in a line. All of the themare off at first. A series of operations is carried out on these lamps. On thei-th operation, the lamps whose numbers is the multiple of I change thecondition (on to off and off).Input Each test case contains only a number n (0Output output The condition of the n-th lamp after infinity operations (0-off, 1-on).Sample Input 15Sample Output 10HintConsider the second test case:The initial condition:0 0 0 0 0 ...After the first Operat
The least oneTime limit:9000/3000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 492 Accepted Submission (s): 184Problem Description in the RPG game ' go back Ice Age ' (I decide to develop the game after my undergraduate education), all Heros has their own respected value, and the skill of killing monsters is defined as the following rule:one hero can Ki LL the monstrers whose respected values is smaller then himself and the both respected values have none common
positive.Input the first line have one integer Q, then Q lines follow. In the Q lines there are an integer Mi, 0Output for each case, there is Q results, in each result, you should output the value of the hero you'll dispatch to C Omplete the task.Sample Input237Sample Output511AuthorwangyeSource2008 "Insigma International Cup" Zhejiang Collegiate Programming Contest-warm up (4)Recommendwangye | We have carefully selected several similar problems for you:1793 1796 1797 1794 1798 test instructio
input; Otherwise 1 Outputfor each grid, output the number of distinct oil deposits. The different pockets is part of the same oil deposit if they is adjacent horizontally, vertically, or diagonally. An oil deposit won't contain more than pockets.Sample INPUT1 1 * 3 5 *@*@* **@** *@*@* 1 8 @@****@* 5 5 ****@ *@@*@ *@**@ @@@*@ @@**@ 0 0Sample Output0 1 22Sourcemid-central USA 1997Recommendeddy | We have carefully selected several similar problems for you:1016 1010 1312 1242 1240//Mark →→1#include
Prime Ring problemTime limit:4000/2000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 28204 Accepted Submission (s): 12561Problem Descriptiona Ring is compose of n circles as shown in diagram. Put Natural number 1, 2, ..., n into each circle separately, and the sum of numbers in the adjacent circles should is a PR Ime.Note:the number of first circle should always be 1.INPUTN (0 Outputthe output format is shown as sample below. Each row represents a series of cir
input data. The first row of each group of data has two positive integer n,m (0Note: There is no relationship between inquiries, it is for the current state!OutputEach set of input data corresponds to one row of output. If you can eliminate the output "YES", you cannot output "no".Sample InputSample OutputYesnonononoyes This topic at that time to pit me an afternoon time .... The code is flawed, and there are always unexpected letters, and the most pit is that dir array elements are not the sam
)Outputfor each data set, your program should output a line which contains the number of tiles he can reach from the Initia L tile (including itself).Sample Input6 9....#......#..............................#@...#.#. #.11 9.#..........#.#######. #.#.....#.. #.#.###.#.. #.#[email protected]#.#. #.#####.#.. #.......#.. #########............ 11 6..#. #.. #....#.. #.. #....#.. #.. ###.. #.. #.. #@...#.. #.. #....#.. #.. #.. 7 7..#.#....#.#. ###.###[email protected]###.###. #.#....#.#.. 0 0Sample Out
Least common multipleTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 38681 Accepted Submission (s): 21606Problem DescriptionGiven two positive integers, calculate the least common multiple of these two numbers.InputThe input contains multiple sets of test data, with only one row per group, including two positive integers not greater than 1000.OutputFor each test case, the least common multiple of these two numbers is given, and each instance ou
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.