P roblem 1 String encoding
Description
Sometimes, you'll have a long string where there are many consecutive identical characters. We want to represent this long string in a string encoding way. For a sequence (length > 1) of the same characters, we can use this character and the number of repetitions, such as "aaaaaa", which we can rewrite as "a6".
Input
A string s of length less than 100 contains only lowercase letters.
Output
Your program should output an encoded string.
Example
Input
aaaaaaabbbbbcerrrrggggggggsssssspoqqqqq |
Output
a7b5cer4g8s6poq5 |
Description
One day, you forget your OJ password and need to set a new one. Please write a program to judge whether the new password conforms to the password rules, the rules are as follows:
The password length must be between 8 and 15.
The password must contain uppercase and lowercase letters.
The password should contain digits or special characters (only #、$、^、&、* ).
The password cannot contain three or more consecutive identical letters or digits ("123", "abc" and "a1a1a1" are legal while "111", "aaa" are illegal).
Tip: You can use regular expressions to complete this problem
<Regular expressions in Java - Tutorial>
Input
The first line only contains one integer n, n>=0.
Then following n lines, which indicate n passwords. The password contains no characters other than letters, digits, and the special characters mentioned above.
Output
Print "True" if the password matches the rules, "False" otherwise. You should verify n passwords and output n lines.
Example
Input
2 Password123 password000 |
Output
True False |
Description
There exists the Fibonacci series ( a0=0,a1=1,a2=1,……). Please write a program to output the append string (a0a1……an) for a given integer n.
Input
An integer n (0<=n<=50)
Output
The append string
Data range
0<=n<=50
Example
Input
3 |
Output
0112 |
You will get many dates (a0,a1,……,an) in format "Year-Month-Day". Your task is to sort them in an ascending order and output a string containing their indices in the input.. If several dates are equal, just sort the dates in the input order. To simplify this task, we assume that every month has 31 days.
Input
Many dates in format "Year-Month-Day"
Output
The append string of the sorting result's index
Data range
1000<=Year<=3000, 1<=Month<=12, 1<=Day<=31, the number of date is no more than 1000
Hint
- You can use hasNext to deal with the input.
- If you want to terminate the input in IDEA, you can use ctrl+D.
Example
2001-4-5 2000-10-27 2000-1-7 2001-4-5 |
2103 |