HDU 1039 Easier done Than said?

Source: Internet
Author: User

Test instructions: Enter more than one string, and then individually determine whether the requirement is met.

Rule one: The password contains at least one vowel letter;

Rule two: It cannot contain three consecutive vowels or three consecutive consonants;

Rule three: it cannot appear the same letter consecutively except for "ee" or "oo".


Import Java.util.scanner;public class Main {public static char[] CHS = {' A ', ' e ', ' I ', ' o ', ' u '};p ublic static void Main (string[] args) {Scanner sc = new Scanner (system.in), while (Sc.hasnext ()) {String s = sc.next (); if (S.equals ("End") {return;}  Boolean flag = Isacceptable (s);//cannot change the value of S = ("<" + S + ">"); if (flag) {s + = "is acceptable.";} else {s + = "are not acceptable. ";} System.out.println (s);}} public static Boolean isacceptable (String str) {if (!isfirstrule (str)) {return false;} if (!issecondrule (str)) {return false;} if (!isthirdrule (str)) {return false;} return true;} public static Boolean isfirstrule (String s) {for (int i = 0; i < s.length (); i++) {if (Isvowel (S, i)) {return true;}} return false;} public static Boolean Isvowel (String s, int i) {//judgment is not vowel for (int j = 0; J < Chs.length; J + +) {if (S.charat (i) = = chs[ J]) {return true;}} return false;} public static Boolean issecondrule (String s) {for (int i = 0; i < s.length ()-2; i++) {Boolean flag = False;if (isvowe L (S, i) {flag = true;} If flag is true, then the subsequent letters must be all vowels to return true;//if flag is false, then the letter must be followed by a full complement to return true;if (flag = = Isvowel (s, i + 1)) {if (flag = = Isvow El (S, i + 2)) {return false;//three vowels or three consonants}}}return true;} public static Boolean isthirdrule (String s) {for (int i = 0; i < s.length ()-1; i++) {Char ch1 = S.charat (i); Char CH2 = S.charat (i + 1); Boolean flag = false;if (ch1 = = ' E ' | | ch1 = = ' o ') {flag = true;} if (ch1 = = CH2) {//returns True when Ch1 and CH2 are vowels, otherwise returns Falsereturn flag;}} Return true;//returns True when CH1CH2 is not equal;}}




Easier done Than said? It's easy to say.Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9876 Accepted Submission (s): 4802


Problem Descriptionpassword security is a tricky thing. Users prefer simple passwords that is easy to remember (like Buddy), but such passwords is often insecure. Password security is a tricky thing to do. Users prefer simple passwords that are easy to remember (such as friends), and such passwords are often unsafe.
Some sites using random computer-generated passwords (like xvtpzyo), some websites use randomly generated passwords (such as Xvtpzyo),
But users had a hard time remembering them and sometimes leave them written on notes stuck to their computer. However, it is sometimes difficult for users to remember them, usually written on notes or stored on their own computers.
One potential solution is to generate "pronounceable" passwords that's relatively secure but still easy to remember.
A viable solution is to generate a "pronounced" password, which is relatively secure, but the password is still easy to remember.
Fnordcom is developing such a password generator. Fnordcom is developing such a password generator.
You work in the Quality Control department, and it's your job to test the generator and make sure that the passwords is a Cceptable. You work in the Quality Control department and your job is to test and ensure that the generated passwords are acceptable.
To is acceptable, a password must satisfy these three rules:
The following three rules must be met if the password is acceptable:
It must contain at least one vowel.
The password contains at least one vowel letter;
It cannot contain three consecutive vowels or three consecutive consonants.
It cannot contain three consecutive vowels or three consecutive consonants;
It cannot contain the consecutive occurrences of the same letter, and except for ' ee ' or ' oo '.
It cannot appear the same letters consecutively except for "ee" or "oo".
(For the purposes of this problem, the vowels is ' a ', ' e ', ' I ', ' o ', and ' u '; all other letters is consonants.) (The range of this problem, vowel ' a ', ' e ', ' o ', ' o ', and ' u ', and all other consonant letters.) )
Note that these rules is not perfect; There is many common/pronounceable words that is not acceptable.
Note that these rules are imperfect; there are many common/pronounced words that are unacceptable.
Inputthe input consists of one or more potential passwords, one per line, followed by a line containing only the word ' end ' That signals the end of the file. The input will contain multiple sets of data, a single test event line, and if the input is "end" it will indicate the end of the input. Each password are at least one and at the most twenty letters long and consists only of lowercase letters.
Each password has a length greater than 0 less than 21 (0,21) and contains only lowercase letters.
Outputfor each password, output whether or not it was acceptable, using the precise format shown in the example.
For each test instance, determine whether it is acceptable. The output format is as follows.
Sample Input
Atvptouibontreszoggaxwiinqeephouctuhend

Sample Output
<a> is acceptable.<tv> are not acceptable.<ptoui> are not acceptable.<bontres> are not ACCEPTABLE.&L T;zoggax> is not acceptable.<wiinq> are not acceptable.<eep> are acceptable.

Sourcemid-central USA 2000

HDU 1039 Easier done Than said?

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.