Easier done Than said?Time
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9845 Accepted Submission (s): 4784
Problem Descriptionpassword security is a tricky thing. Users prefer simple passwords that is easy to remember (like Buddy), but such passwords is often insecure. Some sites use random computer-generated passwords (like Xvtpzyo), but users has a hard time remembering them and Sometim Es leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that's relatively secure but still easy to remember.
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. To is acceptable, a password must satisfy these three rules:
It must contain at least one vowel.
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 '.
(For the purposes of this problem, the vowels is ' a ', ' e ', ' I ', ' o ', and ' u '; all other letters is consonants.) Note that these rules is not perfect; There is many common/pronounceable words that is not acceptable.
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. Each password are at least one and at the most twenty letters long and consists only of lowercase letters.
Outputfor each password, output whether or not it was acceptable, using the precise format shown in the example.
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
Recommendwe has carefully selected several similar problems for you:1062pid=1073 "target=" _blank "style=" Color:rgb (26,92,200); Text-decoration:none ">1073
pid=1043 "target=" _blank "style=" Color:rgb (26,92,200); Text-decoration:none ">1043
pid=1088 "target=" _blank "style=" Color:rgb (26,92,200); Text-decoration:none ">1088 1113
The topic said a lot of nonsense. To say what set password is a complex thing, too simple to set up. No regular and bad memory, in short it means that you want to meet it set password three conditions, meet then give you acceptable otherwise give you not acceptable. (Three conditions in the gaze of ...)
Because the topic is too water. And English also better understand (test instructions or clearer), here do not do too much explanation, Java water too ...
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 Flag1 = False, Flag2 = True, Flag3 = true; String str = Input.next (), if (Str.endswith ("End")) Break;char c[] = Str.tochararray ();//First condition: must include at least one vowel letter for (int i = 0; i < c.length; i++) {if (c[i] = = ' a ' | | c[i] = = ' E ' | | c[i] = = ' I ' | | c[i] = = ' O ' | | c[i] = = ' U ') {Flag1 = True;break;}} Second condition: Cannot include three consecutive vowels or three consecutive consonant letters int a = 0, B = 0;for (int i = 0; i < c.length; i++) {if (c[i] = = ' a ' | | c[i] = = ' E ' | | C[i] = = ' I ' | | C[i] = = ' O ' | | C[i] = = ' U ') {a++;if (a >= 3) {Flag2 = false;} b = 0;} Else{b++;if (b >= 3) {Flag2 = false;} A = 0;}} The third condition: cannot include two consecutive same letters, except for ' ee ' and ' oo ' except for the two cases of int i, j = 0;for (i = 1; i < c.length; i++, J + +) {if (c[i] = = C[j]) {if (c[i] = = ' E ' | | C[i] = = ' O ') continue;else{flag3 = False;break;}}} if (Flag1 && flag2 && flag3) {System.out.println ("<" + str + "> is acceptable. "); Else{system.out.println ("<" + str + "> is not acceptable.");}}}
In addition, onlookers Wang Wei form pattern and Matcher (originally wanted to use this problem to practice the form of ...). But I still don't understand it.
Import Java.util.scanner;import Java.util.regex.matcher;import Java.util.regex.pattern;public class Main {public static void Main (string[] args) throws Exception {Scanner cin = new Scanner (system.in); while (Cin.hasnext ()) {String str = Cin.next (); if (Str.equals ("End")) break; Pattern P1 = Pattern.compile ("[aeiou]{3}|[ ^AEIOU]{3} "); Pattern P2 = pattern.compile ("([a-df-np-z]) \\1"); Pattern p3 = Pattern.compile ("[aeiou]+"); Matcher m = p1.matcher (str); Boolean flag = False;if (!m.find ()) {m = P2.matcher (str); if (!m.find ()) {m = P3.matcher (str); if ( M.find ()) flag = True;}} if (flag) System.out.println ("<" +str+ "> is acceptable."); ElseSystem.out.println ("<" +str+ "> is not acceptable."); Cin.close ();}}
Hdu-1039-easier done Than said? (Java && No, it is my regret ...)