1018 hidden Beihang

Source: Internet
Author: User

Description

ACM International Collegiate Programming Contest-ACM-ICPC, sponsored by association for computer machinery, it is the world's largest and highest-level International College Student program competition. Once a year. ACM was founded in the year following the birth of computer science. It is currently the longest and most authoritative organization in the field of computer science.

ACM International Program Design Competition for college students began in 1970. It aims to enable college students to fully demonstrate their ability to analyze and solve problems through computers. Contestants participating in this competition must at least master common computer science algorithms, basic computing theories (such as discrete mathematics, specific mathematics, and integrated mathematics basics), and data structure basics, programming Language (C/C ++ or Java ). In this competition, the students should not only be able to complete the specified task, but also improve the program running efficiency and space usage based on the function of the program. From the mathematical point of view, the main aspects of the subject are focused on Engineering Mathematics, and abstract mathematics is rarely involved. Generally, requirements and input and output are given as the reference for programming, which is also one of the criteria for verifying Program correctness.

In order to let everyone really original ACM-ICPC competition questions is what kind of, we imitate the style of the competition for everyone to contribute a good enlightening question. I hope this question will be a good start for everyone to join the program design competition. The question is described as follows:

Given a string of uppercase letters, is it possible to erase one or more characters to get the string 'bua '?

Input

The first line contains a single integer T (1 <= T <= 15), the number of test cases.
Each test case is a single line containing at least 1 and at most 100 uppercase letters.
There are no spaces, tabs, lowercase letters or other characters before, or after the string.
Output

For each test case, print the case number and 'yes' if it is possible to get 'bua', or 'no' otherwise.
The output is case-sensitive, so don't output 'yes' or 'yes' when 'yes' should be output.
Example input 4
Acmbuaa
Acmaaub
Helloworld
Buacma sample output Case 1: Yes
Case 2: No
Case 3: No
Case 4: Yes

Solution:
This is a water question. After carefully reading the question, you will deeply feel this point. However, it is important to note that BUAA does not necessarily appear consecutively. Therefore, you must make a judgment.

#include<stdio.h>#include<string.h>main(){    int number,te;    char a[102];    int i,j,k,r;    int length;    int flag;    scanf("%d",&number);    for(te=1;te<=number;te++)    {   flag=0;scanf("%s",&a);length=strlen(a);if(length<=4){flag=0;}else{for(i=0;i<=length-4;i++)if(a[i]=='B'){for(j=i+1;j<=length-3;j++)if(a[j]=='U'){for(k=j+1;k<=length-2;k++)if(a[k]=='A'){for(r=k+1;r<=length-1;r++)if(a[r]=='A')flag=1;}}}}if(flag==1)printf("Case %d: Yes\n",te);elseprintf("Case %d: No\n",te);getchar();    }}

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.