Hdu-5198-strange Class (java+ attention to detail!)

Source: Internet
Author: User

Strange ClassTime limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 634 Accepted Submission (s): 343


Problem DescriptionIn Vivid ' s school, there is a strange class (SC). In SC, the students ' names is very strange. They is in the same format: a n b n c n (A,b,c must not being the same with each other). For example studens whose names is "abc", "Ddppqq" is in SC, however studens whose names is "AAA", "AB", "DDPPQQQ" is not In SC.
Vivid makes friends with so many students, he wants to know who is in SC.
Inputthere was multiple test cases (about ten), each case would give a string S which is the name of Vivid's friend in a sin GLE line.
Please process to the end of file.

[Technical specification]

1≤| S | ≤ Ten .

| s| Indicates the length of S.

S only contains lowercase.
Outputfor each case, output YES if Vivid's friend is the student of SC, otherwise output NO.
Sample Input
Abcbc

Sample Output
YESNO

Sourcebestcoder Round #36 ($)
Recommendhujie | We have carefully selected several similar problems for you:5213 5212 5211 5209 5208

English bad children's shoes, see Finally, this is a bestcoder on the water problem ....
This is a simple question! But pay attention to the details! Official tip: (Simple and clear!) )
1001 Strange Class This is a simple question, first judge the length is not a multiple of 3. Then you can tell if the characters in the last three paragraphs are the same. Finally, judging the characters between the three paragraphs is different.



Import Java.io.*;import java.util.*;p ublic class main{public static void Main (string[] args) {//TODO auto-generated Metho D stubscanner input = new Scanner (system.in); while (Input.hasnext ()) {Boolean flag = true;   String str = Input.nextline (); char c[] = Str.tochararray (); if (c.length% 3 = 0)//is not a multiple of 3 direct False{flag = false;} for (int i = 1; i < (C.LENGTH/3); i++)//first 1/3 not equal direct false{if (c[i]! = C[i-1]) {flag = false;}} for (int i = C.LENGTH/3 + 1; i < (C.length * 2/3); i++)//1/3 to 2/3 are not equal directly false{if (c[i]! = C[i-1]) {flag = False ;}} for (int i = C.length * 2/3 + 1; i < c.length; i++)//2/3 to the last part not equal directly false{if (c[i]! = C[i-1]) {flag = false;} }if (! (                                       C[0] = C[c.length/3] && c[0]! = c[c.length-1] && C[C.LENGTH/3]! = C[c.length-1])) {flag = false; Divided into three parts of the number to be different!} if (flag) {System.out.println ("yes");} else{system.out.println ("NO");}}}





The Chinese explanation is as follows:
Strange Classaccepts:519submissions:1749Time limit:2000/1000 MS (java/others)Memory limit:65536/65536 K (java/others) Problem description
In Vivid's school, there is a strange class (SC). In SC, the names of these students are very strange. Their name form is like this.
   
      a  n   b  n   c  n 
   (A,b,c 22 is not the same.) For example, "abc", "DDPPQQ" Students are in SC, however called "AAA", "AB", "DDPPQQQ" classmate is not in SC. Vivid has made a lot of friends, and he wants to know which of them are in SC.
Enter a description
Multiple sets of test data (presumably
    
        ten   
  
 
    
 Group), each data in a row gives a string s, representing vivid a friend's name. Please process to the end of the file. [Parameter conventions]
   
    
        1≤| S   | ≤   .   
 

    
   | s| Refers to the length of S. s contains only lowercase letters.
Output description
For each data, if the friend of Vivid is SC, then output yes, otherwise output No.
Input sample
Abcbc
Output sample
YESNO


Hdu-5198-strange Class (java+ attention to detail!)

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.