 从字符串中提取最后的 n 个字符

How can I get the last n characters from a string in R? Is there a function like SQL's RIGHT?
转载于:https://stackoverflow.com/questions/7963898/extractingthelastncharactersfromastringinr
I'm not aware of anything in base R, but it's straightforward to make a function to do this using substr
and nchar
:
x < "some text in a string"
substrRight < function(x, n){
substr(x, nchar(x)n+1, nchar(x))
}
substrRight(x, 6)
[1] "string"
substrRight(x, 8)
[1] "a string"
This is vectorised, as @mdsumner points out. Consider:
x < c("some text in a string", "I really need to learn how to count")
substrRight(x, 6)
[1] "string" " count"
If you don't mind using the stringr
package, str_sub
is handy because you can use negatives to count backward:
x < "some text in a string"
str_sub(x,6,1)
[1] "string"
Or, as Max points out in a comment to this answer,
str_sub(x, start= 6)
[1] "string"
 localhost I believe stringr had been remade using stringi as a backend, so should work with NAs etc. now.
 大约 4 年之前 回复
 ℡Wang Yan stringr doesn't work well with NA's value and all encoding. I strongly reccomend stringi package :)
 6 年多之前 回复
 必承其重  欲带皇冠 also, str_sub(x,start=n) gets n last characters.
 接近 9 年之前 回复
A simple base R solution using the substring()
function (who knew this function even existed?):
RIGHT = function(x,n){
substring(x,nchar(x)n+1)
}
This takes advantage of basically being substr()
underneath but has a default end value of 1,000,000.
Examples:
> RIGHT('Hello World!',2)
[1] "d!"
> RIGHT('Hello World!',8)
[1] "o World!"
Another reasonably straightforward way is to use regular expressions and sub
:
sub('.*(?=.$)', '', string, perl=T)
So, "get rid of everything followed by one character". To grab more characters off the end, add however many dots in the lookahead assertion:
sub('.*(?=.{2}$)', '', string, perl=T)
where .{2}
means ..
, or "any two characters", so meaning "get rid of everything followed by two characters".
sub('.*(?=.{3}$)', '', string, perl=T)
for three characters, etc. You can set the number of characters to grab with a variable, but you'll have to paste
the variable value into the regular expression string:
n = 3
sub(paste('.+(?=.{', n, '})', sep=''), '', string, perl=T)
Try this:
x < "some text in a string"
n < 5
substr(x, nchar(x)n, nchar(x))
It shoudl give:
[1] "string"
An alternative to substr
is to split the string into a list of single characters and process that:
N < 2
sapply(strsplit(x, ""), function(x, n) paste(tail(x, n), collapse = ""), N)
someone before uses a similar solution to mine, but I find it easier to think as below:
> text<"some text in a string" # we want to have only the last word "string" with 6 letter
> n<5 #as the last character will be counted with nchar(), here we discount 1
> substr(x=text,start=nchar(text)n,stop=nchar(text))
This will bring the last characters as desired.
Use stri_sub
function from stringi
package.
To get substring from the end, use negative numbers.
Look below for the examples:
stri_sub("abcde",1,3)
[1] "abc"
stri_sub("abcde",1,1)
[1] "a"
stri_sub("abcde",3,1)
[1] "cde"
You can install this package from github: https://github.com/Rexamine/stringi
It is available on CRAN now, simply type
install.packages("stringi")
to install this package.
I used the following code to get the last character of a string.
substr(output, nchar(stringOfInterest), nchar(stringOfInterest))
You can play with the nchar(stringOfInterest) to figure out how to get last few characters.
str = 'This is an example'
n = 7
result = substr(str,(nchar(str)+1)n,nchar(str))
print(result)
> [1] "example"
>
Finding string 字符串的查找问题_course
20190825Problem Description Richard is a smart data analyst in a famous company. One of his daily boring work is to find how many times does a pattern string occur in a very long string. Luckily, Richard notices that there are many consecutive repeated substrings in this very long string, so he uses the following compression algorithm to make the string shorter: a). Find a noncompressed consecutive repeated substring of the original string, e.g. “ab” in “cabababd”. b). Replace the repeating part with the bracketed repetend, followed by the times the repetend appears in the original string. e.g. Write “cabababd” as “c[ab]3d”. Note she can also write it as “c[ab]1ababd” or “ca[ba]2bd” and so on, although these string are not compressed as well as the first one is. c). Repeat a) and b) several times until the string is short enough. However, Richard finds it still a bit hard for him to do his work after the compression. So he orders you to write a program to make his work easier. Can you help him? Input The input contains several test cases, terminated by EOF. The number of test cases does not exceed 10000. Each test case contains two lines, denote the compressed text and pattern string. The decompressed text and pattern string contain lowercase letter only. The first line contains only lowercase letters (az), square brackets ([]) and numbers (09), and the second line contains only lowercase letters (az). The brackets must be followed with an integer t(1≤t≤2311)indicating the times the string in the brackets repeat. The brackets won't be nested. You can assume the length of the compressed string and pattern string won't exceed 500. Please note that for most test cases, the length of the pattern string is relatively very small. Output For each test case, print a single line containing the times this pattern string occurs in the very long string. Sample Input [ab]10aaba ba Sample Output 11
判断是否是substring的一个问题，怎么利用C程序的语言的程序设计的代码去实现判断的_course
20190602Problem Description You hava a nonempty string which consists of lowercase English letters and may contain at most one '?'. Let's choose nonempty substring G from S (it can be G = S). A substring of a string is a continuous subsequence of the string. if G contains '?' then '?' can be deleted or replaced by one of lowercase english letters. After that if each letter occurs even number of times in G then G is a good substring. Find number of all good substrings. Input The input consists of an integer T, followed by T lines, each containing a nonempty string. The length of the string doesn't exceed 20000. [Technical Specification] 1 <= T <= 100 Output For each test case, print a single integer which is the number of good substrings of a given string. Sample Input 3 abc?ca aabbcc aaaaa Sample Output 7 6 6
Finding string 字符串的查找_course
20200215Problem Description Richard is a smart data analyst in a famous company. One of his daily boring work is to find how many times does a pattern string occur in a very long string. Luckily, Richard notices that there are many consecutive repeated substrings in this very long string, so he uses the following compression algorithm to make the string shorter: a). Find a noncompressed consecutive repeated substring of the original string, e.g. “ab” in “cabababd”. b). Replace the repeating part with the bracketed repetend, followed by the times the repetend appears in the original string. e.g. Write “cabababd” as “c[ab]3d”. Note she can also write it as “c[ab]1ababd” or “ca[ba]2bd” and so on, although these string are not compressed as well as the first one is. c). Repeat a) and b) several times until the string is short enough. However, Richard finds it still a bit hard for him to do his work after the compression. So he orders you to write a program to make his work easier. Can you help him? Input The input contains several test cases, terminated by EOF. The number of test cases does not exceed 10000. Each test case contains two lines, denote the compressed text and pattern string. The decompressed text and pattern string contain lowercase letter only. The first line contains only lowercase letters (az), square brackets ([]) and numbers (09), and the second line contains only lowercase letters (az). The brackets must be followed with an integer t(1≤t≤2311)indicating the times the string in the brackets repeat. The brackets won't be nested. You can assume the length of the compressed string and pattern string won't exceed 500. Please note that for most test cases, the length of the pattern string is relatively very small. Output For each test case, print a single line containing the times this pattern string occurs in the very long string. Sample Input [ab]10aaba ba Sample Output 11
从字符串中提取最后的 n 个字符_course
20111101<div class="posttext" itemprop="text"> <p>How can I get the last n characters from a string in R? Is there a function like SQL's RIGHT?</p> </div> <p>转载于:https://stackoverflow.com/questions/7963898/extractingthelastncharactersfromastringinr</p>
Maximum repetition substring 字符串的问题_course
20191227Problem Description The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "ababab" is 3 and "ababa" is 1. Given a string containing lowercase letters, you are to find a substring of it with maximum repetition number. Input The input consists of multiple test cases. Each test case contains exactly one line, which gives a nonempty string consisting of lowercase letters. The length of the string will not be greater than 100,000. The last test case is followed by a line containing a '#'. Output For each test case, print a line containing the test case number( beginning with 1) followed by the substring of maximum repetition number. If there are multiple substrings of maximum repetition number, print the lexicographically smallest one. Sample Input ccabababc daabbccaa # Sample Output Case 1: ababab Case 2: aa
Just a String 字符串的一个问题_course
20200127Problem Description A substring of a string is a successive part of the string. Given a string your task is to find out the Kth alphabet order substring of the original string. For example, the string "ABC" contains six substrings: "A" "AB" "ABC" "B" "BC" "C" (in alphabet order) and string "BBC" also contains six substrings: "B" "B" "BB" "BBC" "BC" "C" (in alphabet order) Input The input contains several test cases, the first line of input contains the number of test cases. For each test case, there is only one line contains the string S of length N, followed by a integer K. (1 <= K <= N*(N+1)/2, 1 <= N <= 100000, S contains only letters and digits) Output For each test cases, output the Kth alphabet order substring. Sample Input 2 ABC 2 BBC 3 Sample Output Case 1: AB Case 2: BB
KMP序列匹配算法的一个实现原理问题，采用C语言方式的编程计算_course
20190314Problem Description When the problem to match S string in T string is mentioned, people always put KMP, AhoCorasick and Suffixarray forward. But Mr Liu tells Canoe that there is an algorithm called Burrows–Wheeler Transform(BWT) which is quite amazing and highefficiency to solve the problem. But how does BWT work to solve the matching SinT problem? Mr Liu tells Canoe the firstly three steps of it. Firstly, we append the ‘$’ to the end of T and for convenience, we still call the new string T. And then for every suffix of T string which starts from i, we append the prefix of T string which ends at (i – 1) to its end. Secondly, we sort these new strings by the dictionary order. And we call the matrix formed by these sorted strings Burrows Wheeler Matrix. Thirdly, we pick characters of the last column to get a new string. And we call the string of the last column BWT(T). You can get more information from the example below. Then Mr Liu tells Canoe that we only need to save the BWT(T) to solve the matching problem. But how and can it? Mr Liu smiles and says yes. We can find whether S strings like “aac” are substring of T string like “acaacg” or not only knowing the BWT(T)! What an amazing algorithm BWT is! But Canoe is puzzled by the tricky method of matching S strings in T string. Would you please help Canoe to find the method of it? Given BWT(T) and S string, can you help Canoe to figure out whether S string is a substring of string T or not? Input There are multiple test cases. First Line: the BWT(T) string (1 <= length(BWT(T)) <= 100086). Second Line: an integer n ( 1 <=n <= 10086) which is the number of S strings. Then n lines comes. There is a S string (n * length(S) will less than 2000000, and all characters of S are lowercase ) in every line. Output For every S, if S string is substring of T string, then put out “YES” in a line. If S string is not a substring of T string, then put out “NO” in a line. Sample Input gc$aaac 2 aac gc Sample Output YES NO
Boolean String Expression 字符串表达式_course
20200107Problem Description Mike needs a bike and he decides to buy a secondhand one to save money. Luckily, he has found a secondhand goods BBS. However, there are so many messages there and it will be extremely boring for him to look through all those messages and figure out which one contains the information he needs. So he decides to write a program to do this. The problem is: how to determine whether a message is about selling a bike. Mike decides to use a keywordfindbased algorithm. First choose some keywords and then the program checks whether a message contains these keywords or not. For example, he wants to find messages that contain 'bike'，and at the same time have 'sell' or don't have 'buy' ("bike on sell", "bike", "sell bike and buy …"are all what he needs, but "buy bike" is not). Of course he wants his program can be used to handle things more than buying a bike. As the string matching nature of the keywordfindbased algorithm, regular expression should be quite suitable here. But after a second thought, he throws it away: he even can't figure out what the corresponding regular expression is for a simple query "don't have the word 'buy'". After further thinking of this problem, Mike comes up with a great idea: combining string matching with Boolean algebra! He names it as "Boolean String Expression". Formally, a Boolean String Expression is composed of normal strings, ‘&’(and), ‘’(or) and ‘!’(not). A Boolean String Expression s matches a message M when: 1. s is a normal string, and it's a substring of M 2. s = a & b, a and b are both Boolean String Expressions that match M 3. s = a  b, a and b are both Boolean String Expressions, and at least one of them matches M 4. s = ! a, a is Boolean String Expression which doesn't match M Precedence of the three operators is: ‘!’ > ‘&’ > ‘’. And parenthesis can be used to change precedence of operators. Mike's query can be easily expressed as: bike & (sell  !buy) Mike is very satisfied with this solution, but he comes to another problem: nearly all expressions can be changed into another form with the same meaning. For example, "bike & (sell  !buy)" has a equivalent form of: (bike & sell)  (bike & !buy) It may seem to be obvious to you. However, it confuses Mike a lot and he needs your help to write a problem to check whether two Boolean String Expressions are equivalent. (Equivalent here means: all messages that match one expression will match the other, all messages that don't match one expression will not match the other too) Input The first line contains an integer indicating the number of test cases (<=30). Each test case contains three lines: The first line is an alphabet that contains only lower case letters. Suppose all messages we care about are only composed of those letters. The second line and 3rd line are two Boolean String Expressions. The expression contains only characters from the alphabet and '&', '', '!' , and its length is no more than 20. Output For each test case, output a line of 'Yes' if the two expressions are equivalent, 'No' otherwise. Sample Input 4 abcdefghijklmnopqrstuvwxyz bike&(sell!buy) bike&sellbike&!buy abc a&(bc) a&bc ab ab&!a ab&!b ab ab a!a Sample Output Yes No Yes No
The Number of Palindromes_course
20190823Problem Description Now, you are given a string S. We want to know how many distinct substring of S which is palindrome. Input The first line of the input contains a single integer T(T<=20), which indicates number of test cases. Each test case consists of a string S, whose length is less than 100000 and only contains lowercase letters. Output For every test case, you should output "Case #k:" first in a single line, where k indicates the case number and starts at 1. Then output the number of distinct substring of S which is palindrome. Sample Input 3 aaaa abab abcd Sample Output Case #1: 4 Case #2: 4 Case #3: 4
编程的字母的问题，BWT_course
20190827Problem Description When the problem to match S string in T string is mentioned, people always put KMP, AhoCorasick and Suffixarray forward. But Mr Liu tells Canoe that there is an algorithm called Burrows–Wheeler Transform(BWT) which is quite amazing and highefficiency to solve the problem. But how does BWT work to solve the matching SinT problem? Mr Liu tells Canoe the firstly three steps of it. Firstly, we append the ‘$’ to the end of T and for convenience, we still call the new string T. And then for every suffix of T string which starts from i, we append the prefix of T string which ends at (i – 1) to its end. Secondly, we sort these new strings by the dictionary order. And we call the matrix formed by these sorted strings Burrows Wheeler Matrix. Thirdly, we pick characters of the last column to get a new string. And we call the string of the last column BWT(T). You can get more information from the example below. Then Mr Liu tells Canoe that we only need to save the BWT(T) to solve the matching problem. But how and can it? Mr Liu smiles and says yes. We can find whether S strings like “aac” are substring of T string like “acaacg” or not only knowing the BWT(T)! What an amazing algorithm BWT is! But Canoe is puzzled by the tricky method of matching S strings in T string. Would you please help Canoe to find the method of it? Given BWT(T) and S string, can you help Canoe to figure out whether S string is a substring of string T or not? Input There are multiple test cases. First Line: the BWT(T) string (1 <= length(BWT(T)) <= 100086). Second Line: an integer n ( 1 <=n <= 10086) which is the number of S strings. Then n lines comes. There is a S string (n * length(S) will less than 2000000, and all characters of S are lowercase ) in every line. Output For every S, if S string is substring of T string, then put out “YES” in a line. If S string is not a substring of T string, then put out “NO” in a line. Sample Input gc$aaac 2 aac gc Sample Output YES NO
Match 的计算_course
20191120Problem Description Given three strings, find the length of the longest string which is a substring of each of the three input strings. In this problem "substring" has the usual definition. A string X is a substring of a string Y if and only if string X can be created from string Y by deleting zero or more consecutive characters from the start of string Y, and deleting zero or more consecutive characters from the end of string Y. Input The first line of the input is the number of test cases (less than 3000). For each case there is three lines each contains a string. The string only contains 'a''z' and up to 1000 characters long. There is a blank line before each test case. Output For each test case output the answer on a line. Sample Input 3 aebcd ebcaddwerd fdsalebcser sdafawerrsdfsdfwe erfasdfafsd egreetsdwere aaaaa aaaaa aaaaa Sample Output 3 2 5
The most binary substring 如何来编写呢_course
20191207Problem Description Everybody knows the number is saved with the binary string in the computer. Now, their have N (1 <= N <= 1000) binary strings I tell you, your task is tell me what is the most binary substring with K (1 <= K <= L) characters in the strings I give you. The length of each string is L (1 <= L <= 60). Output times of the most appearing binary substring. Input Each line will contain three numbers N, L, K. Following N lines, represent N binary strings. Output One answer one line. Sample Input 2 6 3 101011 110101 2 6 4 101011 110101 Sample Output 4 2
Just a String 字符串的问题_course
20200818Problem Description A substring of a string is a successive part of the string. Given a string your task is to find out the Kth alphabet order substring of the original string. For example, the string "ABC" contains six substrings: "A" "AB" "ABC" "B" "BC" "C" (in alphabet order) and string "BBC" also contains six substrings: "B" "B" "BB" "BBC" "BC" "C" (in alphabet order) Input The input contains several test cases, the first line of input contains the number of test cases. For each test case, there is only one line contains the string S of length N, followed by a integer K. (1 <= K <= N*(N+1)/2, 1 <= N <= 100000, S contains only letters and digits) Output For each test cases, output the Kth alphabet order substring. Sample Input 2 ABC 2 BBC 3 Sample Output Case 1: AB Case 2: BB
BWT问题的求解的一个过程问题_course
20190825Problem Description When the problem to match S string in T string is mentioned, people always put KMP, AhoCorasick and Suffixarray forward. But Mr Liu tells Canoe that there is an algorithm called Burrows–Wheeler Transform(BWT) which is quite amazing and highefficiency to solve the problem. But how does BWT work to solve the matching SinT problem? Mr Liu tells Canoe the firstly three steps of it. Firstly, we append the ‘$’ to the end of T and for convenience, we still call the new string T. And then for every suffix of T string which starts from i, we append the prefix of T string which ends at (i – 1) to its end. Secondly, we sort these new strings by the dictionary order. And we call the matrix formed by these sorted strings Burrows Wheeler Matrix. Thirdly, we pick characters of the last column to get a new string. And we call the string of the last column BWT(T). You can get more information from the example below. Then Mr Liu tells Canoe that we only need to save the BWT(T) to solve the matching problem. But how and can it? Mr Liu smiles and says yes. We can find whether S strings like “aac” are substring of T string like “acaacg” or not only knowing the BWT(T)! What an amazing algorithm BWT is! But Canoe is puzzled by the tricky method of matching S strings in T string. Would you please help Canoe to find the method of it? Given BWT(T) and S string, can you help Canoe to figure out whether S string is a substring of string T or not? Input There are multiple test cases. First Line: the BWT(T) string (1 <= length(BWT(T)) <= 100086). Second Line: an integer n ( 1 <=n <= 10086) which is the number of S strings. Then n lines comes. There is a S string (n * length(S) will less than 2000000, and all characters of S are lowercase ) in every line. Output For every S, if S string is substring of T string, then put out “YES” in a line. If S string is not a substring of T string, then put out “NO” in a line. Sample Input gc$aaac 2 aac gc Sample Output YES NO
如何重复输出这里的数字的序列的，采用C程序的语言的设计的办法_course
20190411Problem Description Cloud gets a string which contains only lowercase letters from Miceren as a birthday gift. Since Cloud hates repeating, if a substring can be divided into several equal strings, she will be very disgusted. For example, "abcabcabc" is very disgusting for her, but "abca" is just ok. Now, Cloud wants to know how many nonempty substring would not disgust her. As you know, Miceren is not good at counting, can you help him? Input The first line contains a single integer T, indicating the number of test cases. Each test case contains only one line, containing the string. T is about 10. The length of string will not exceed 100100. Output For each test case, print the answer. Sample Input 1 abcabc Sample Output 20
C语言来实现 string_course
20190827Problem Description Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if (i) It is of length M*L; (ii) It can be constructed by concatenating M “diversified” substrings of S, where each of these substrings has length L; two strings are considered as “diversified” if they don’t have the same character for every position. Two substrings of S are considered as “different” if they are cut from different part of S. For example, string "aa" has 3 different substrings "aa", "a" and "a". Your task is to calculate the number of different “recoverable” substrings of S. Input The input contains multiple test cases, proceeding to the End of File. The first line of each test case has two spaceseparated integers M and L. The second ine of each test case has a string S, which consists of only lowercase letters. The length of S is not larger than 10^5, and 1 ≤ M * L ≤ the length of S. Output For each test case, output the answer in a single line. Sample Input 3 3 abcabcbcaabc Sample Output 2
Palindromic Substring 回文字符串问题_course
20200226Problem Description In the kingdom of string, people like palindromic strings very much. They like only palindromic strings and dislike all other strings. There is a unified formula to calculate the score of a palindromic string. The score is calculated by applying the following three steps. 1. Since a palindromic string is symmetric, the second half (excluding the middle of the string if the length is odd) is got rid of, and only the rest is considered. For example, "abba" becomes "ab", "aba" becomes "ab" and "abacaba" becomes "abac". 2. Define some integer values for 'a' to 'z'. 3. Treat the rest part as a 26based number M and the score is M modulo 777,777,777. However, different person may have different values for 'a' to 'z'. For example, if 'a' is defined as 3, 'b' is defined as 1 and c is defined as 4, then the string "accbcca" has the score (3×263+4×262+4×26+1) modulo 777777777=55537. One day, a very long string S is discovered and everyone in the kingdom wants to know that among all the palindromic substrings of S, what the one with the Kth smallest score is. Input The first line contains an integer T(1 ≤ T ≤ 20), the number of test cases. The first line in each case contains two integers n, m (1 ≤ n ≤ 100000, 1 ≤ m ≤ 20) where n is the length of S and m is the number of people in the kingdom. The second line is the string S consisting of only lowercase letters. The next m lines each containing 27 integers describes a person in the following format. Ki va vb ... vz Where va is the value of 'a' for the person, vb is the value of 'b' and so on. It is ensured that the Kith smallest palindromic substring exists and va, vb, ..., vz are in the range of [0, 26). But the values may coincide. Output For each person, output the score of the Kth smallest palindromic substring in one line. Print a blank line after each case. Sample Input 3 6 2 abcdca 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 4 10 zzzz 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 51 4 abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba 1 1 3 3 25 20 25 21 7 0 9 7 3 16 15 14 19 5 19 19 19 22 8 23 2 4 1 25 1 3 3 25 20 25 21 7 0 9 7 3 16 15 14 19 5 19 19 19 22 8 23 2 4 1 26 1 3 3 25 20 25 21 7 0 9 7 3 16 15 14 19 5 19 19 19 22 8 23 2 4 1 76 1 3 3 25 20 25 21 7 0 9 7 3 16 15 14 19 5 19 19 19 22 8 23 2 4 1 Sample Output 1 620 14 14 14 14 14 14 14 378 378 378 0 9 14 733665286
Compressed String 字符串的压缩_course
20191230Problem Description Dealing with super long character strings is Chris’s daily work. Unfortunately, the strings are so long that even the fastest computer in the world cannot work with them. Chris does her work in a smart way by compressing the strings into shorter expressions. She does her compression for each string in the following way: a) Find a consecutive repeated substring of the original string, e.g. “ab” in “cabababd”. b) Replace the repeating part with the bracketed repetend, followed by the times the repetend appears in the original string. e.g. Write “cabababd” as “c[ab]3d”. Note she can also write it as “c[ab]1ababd” or “ca[ba]2bd” and so on, although these string are not compressed as well as the first one is. c) Repeat a) and b) several times until the string is short enough. Chris does her compression quite well. But as you know, the work is boring and a waste of time. Chris has written a computer program to help her do the boring work. Unfortunately, there is something wrong with the program; it often outputs an incorrect result. To help her debug the program, you are ordered to write a debugger which can compare Chris’s standard compressed string against the string compressed by the program. Input There are multiple test cases. The first line of the input contains an integer T, meaning the number of the test cases. For each test case, there are two lines of character strings which the first one is Chris’s standard compressed string and the second one is the program’s compressed string. Both string contains only lowercase letters (az), square brackets ([]) and numbers (09). The brackets must be followed with an integer indicating the times the string in the brackets repeat, note that the repeat time can be zero. The brackets can be nested. You can assume all the compressed strings in the input are no longer than 20. See further details in the input sample. Output For each test case, output case number first. And then if the two uncompressed strings are the same, output “YES” in a single line; otherwise, output “NO” followed by the first position where the uncompressed strings differ. Sample Input 5 a[a]12 [[a]3]4a [z]12 zzzzzzzzz [a[ba]2b]12 [ab]36 [a]123123123[icpc]2 [[a]123]1001001inter aismoreeasierthanc gismuchharderthanj Sample Output Case #1: YES Case #2: NO 10 Case #3: YES Case #4: NO 123123125 Case #5: NO 1
R语言入门基础
20190601本课程旨在帮助学习者快速入门R语言： 课程系统详细地介绍了使用R语言进行数据处理的基本思路和方法。 课程能够帮助初学者快速入门数据处理。 课程通过大量的案例详细地介绍了如何使用R语言进行数据分析和处理 课程操作实际案例教学，通过编写代码演示R语言的基本使用方法和技巧
 [HarmonyOS][鸿蒙专栏开篇]快速入门OpenHarmony的LiteOS微内核 1557220200913文章目录1、获取源码2、什么是LiteOS3、LiteOS的目录介绍4、LiteOS 中Make体系5、LiteOS 中Kconfig的配置5.1、顶层Kconfig5.2、具体板级的deconfig文件6、编译7、顶层目录下的config.mk文件主要完成如下功能的配置： 1、获取源码 OpenHarmony是HarmonyOS的开源版，由华为捐赠给开放原子开源基金会（OpenAtom Foundation）开源。第一个开源版本支持在128KB~128MB设备上运行，欢迎参加开源社区一起持续演进。 代码.
 12.42MB
华为机考题库(全）
20121222包括招聘的机考题，及面试过程中会问到的数据结构的相关内容，排序算法全部包括并且有改进算法，一点点改进可以让你表现的与众不同，如果好的话给点评价吧亲
 14.93MB
2020年研究生数学建模A题最佳参考资料.zip
20200917时间过的真快，又到了2020年的研究生数学建模竞赛，经过本人一天的时间相关论文资料搜索，发现这几篇论文对于华为题《ASIC芯片上的载波恢复DSP算法设计与实现》具有一定的参考价值，仅供参考，祝大家建模
 35岁以上的程序员们，后来都干什么去了？ 1775720200909摘要：对于多数程序员来说，40岁之前赚到别人60岁的钱是普遍目标，不过职业的进阶也印证着人生的进阶，所以何时开始思考未来的职业规划，都不算早。 知乎上有个话题叫做“程序员的悲哀是什么？”，有个高赞回复直戳大多数程序员的命门：“最大的悲哀就是以为自己挣到了很多钱，其实根本不懂怎么挣钱，随着年龄的增长，工作瓶颈越来越多，越来越容易受到歧视，却不知道怎么走下去！” 程序员老实、爱学习，也是最有危机感的群体之一，他们每天在GitHub、各大技术论坛上如饥似渴地汲取对自己最有帮助的技术知识，同时怕时间精力跟不上高
 下载 Python实现的爬虫刷回复功能示例
 博客 CTF学习笔记——Include&Ping Ping Ping
 博客 2020920 忙
 博客 ASP.NET Core 在Controller的构造函数中设置ViewBag无效，NullReferenceException: Object reference not set to an in
 下载 pandas表连接 索引上的合并方法
 下载 Python简单实现网页内容抓取功能示例
 博客 学习笔记3【图形界面与命令行】
 下载 Anaconda 离线安装 python 包的操作方法
 下载 vs2008(sp1)运行库(包括Debug和Release版)
 学院 平面设计+视频剪辑大师课终极套餐
 学院 深度学习工程师实战就业系列
 博客 wordpress网站标题动态优化的几种形式
 学院 vueelementadmin开发后台权限模块
 学院 移动端自动化测试入门（Appium）
 博客 独热编码
 博客 标准C库对文件操作的引入
 博客 ASN decoding example
 博客 操作系统学习（1）动态分区分配算法
 学院 物联网大数据实时分析平台
 博客 Idea 同样的症状不同的病需要不同的配方
 下载 Java数组.xmind
 博客 Linux Lab is a set of realtime labs for Linux kernel learning
 下载 一个实际LiHiPd多功能智能充电器
 下载 基于anaconda下强大的conda命令介绍
 博客 29 .课程管理时长计算 时间显示优化 事务配置
 学院 C#之面向对象
 下载 java面向对象编程总结.zip
 博客 纯css画小黄人
 博客 AttributeError: ‘NoneType‘ object has no attribute ‘dim BN层
 博客 牛客小白月赛28 G 牛牛和字符串的日常(KMP)