2018 National multi-school algorithm winter training Camp Practice Competition (second session)

Source: Internet
Author: User

Question A:

Links: Https://www.nowcoder.com/acm/contest/74/A
Source: Niu Ke Net

Small fish spit bubble, toot toot out. Small fish will spit out two kinds of bubbles: Big bubble "o", Small bubble "O". Two adjacent small bubbles will melt into a large bubble, two adjacent large bubbles will explode. (Yes, you're right, little bubbles and bubbles don't make any difference, and I don't know why.) For example: Oooooooo will become OO after a period of time.
Input Description:
The data has multiple groups and is processed to the end of the file.
Each set of inputs contains a single row of ' O ' and ' O ' strings.
Output Description:
Each set of outputs contains only one row, and the output line string represents the bubbles that the small fish spit out after fusion.

Example 1 input
Oooooooo
Output
Oo
Description
Merge from left to right
Note:
For 100% of data,
The length of the string does not exceed 100.
#include <bits/stdc++.h>using namespacestd;//const int INF =0x3f3f3f3f;//int sum[1005][1005];//int dp[1005][1005];intdp[ the];intMain () {strings;  while(Cin >>s) {stringstring1 ="";  for(intI=0; i < s.length (); i++) {string1= S[i] +string1; }        intLENS =string1.length (); intt =Lens;  while(1)        {            if(T = =0)                 Break; if(string1[t-1] = = string1[t-2])            {                if(string1[t-1] =='o')                {                    if(T <string1.length ()) {                        stringStemp = String1.substr (T,string1.length ()-t); String1= String1.substr (0, T2); String1+='O'; String1+=stemp; T=string1.length (); }                    Else{string1= String1.substr (0, T2); String1+='O'; T=string1.length (); }                }                Else if(string1[t-1] =='O')                {                    if(T <string1.length ()) {                        stringStemp = String1.substr (T,string1.length ()-t); String1= String1.substr (0, T2); String1+=stemp; T=string1.length (); }                    Else{string1= String1.substr (0, T2); T=string1.length (); }                }            }            Else{T= T1; }        }        stringstring2 ="";  for(intI=0; i < string1.length (); i++) {string2= String1[i] +string2; } cout<< string2 <<Endl; }    return 0;}

Wrote an h, long a lump.

Question B

Links: Https://www.nowcoder.com/acm/contest/74/D
Source: Niu Ke Net

Title Description
Wozuinb like to play the stone legend, but the food is not good, so he decided to play the arena to practice practiced hand. System in order to give n cards, each card has its own use consumption a[i], each time only give one, WOZUINB can choose or discard this card. Each card selected will be placed in the order of selection in the card slot, when the card slot is filled with 30 sheets can form a set of cards. Wozuinb hope that the consumption of his deck meets a smooth curve, that is, 30 cards are satisfied with the first card consumption is not less than the I-1 (i>1). Please help WOZUINB take a look, these cards can make up the desired deck, if you can compose the output "yes", if you cannot output "no".
Input Description:
The first line enters an integer n,0<n<100.
The second line enters a line of numbers a[i], each number is separated by a space, representing the consumption of the card that appears on the first sheet.
Output Description:
Output one line, "yes" or "no"
Example 1 input
51 2 3) 4 5
Output
No
#include <bits/stdc++.h>using namespacestd;//const int INF =0x3f3f3f3f;//int sum[1005][1005];//int dp[1005][1005];intdp[ the];intMain () {intN; CIN>>N; inta[ the];  for(intI=0; I < the; i++) Dp[i]=1;  for(intI=1; I <= n;i++) Cin>>A[i];  for(intI=1; I <= n;i++)    {         for(intj=1; J < i;j++)        {            if(A[i] >=A[j]) {Dp[i]= Max (dp[i],dp[j]+1); }        }    }    intAns =0;  for(intI=1; I <= n;i++) {ans=Max (ans,dp[i]); }    if(Ans >= -) cout<<"Yes"<<Endl; Elsecout<<"No"<<Endl; return 0;}

The longest non-descending subsequence is a bare question.

Question H

Links: Https://www.nowcoder.com/acm/contest/74/H
Source: Niu Ke Net

Title Description
Since it is the end of the Bureau, we will play random numbers. It is known that the first 10 items of a series are {0, 1, 1, 2, 4, 7, 13, 24, 44, 81} Small G not satisfied: I want more number!!! No, I won't let you play. The little G will ask you what number is the nth item, please answer this naughty child.
Input Description:
Multiple sets of data input and output;
The first line enters an integer n (1<=n<=50)
Output Description:
The number of nth in the output sequence.
Example 1 input
123
Output
011
#include <bits/stdc++.h>using namespacestd;//const int INF =0x3f3f3f3f;//int sum[1005][1005];//int dp[1005][1005];intMain () {Long Longa[ -]; a[1] =0; a[2] =1; a[3] =1;  for(intI=4; I <= Wu; i++) {A[i]= a[i-3] + a[i-2] + a[i-1]; }    intN;  while(Cin >>N) {cout<< A[n] <<Endl; }    return 0;}

Find a regular +longlong

Only 3 questions were written, too much food, and later the problem.

2018 National multi-school algorithm winter training Camp Practice Competition (second session)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.