-->
当前位置:首页 > 题库

PROGRAMMING:Matching pi

Luz5年前 (2021-05-10)题库549
Using KMP algorithm to realize string matching, you must be familiar with it in class, but let's talk about PI first. Some people guess that the fractional part of irrational number contains big secrets in the universe, such as your birthday, your boyfriend / girlfriend's birthday, and even your bank card account number and password. It's impossible to exhaust it, but we can examine the previous part.
In this topic, it is not allowed to use string matching algorithm built in programming language, such as StrCmp in C language.
*If you want to find your own information, you can visit [the PI search page]( http://www.angio.net/pi/ )*
###Input format:
The input is two lines, the first line is the excerpt s of the fractional part of PI, and the length is no more than $$10 ^ 6 $$; The second line is the number string t to find, which is no more than $$10 ^ 6 $. It can be assumed that the inputs are numbers like 0 ~ 9.
###Output format:
Output the position where t first appears in S. If t does not appear in s, output - 1, ending with a new line.
###Input sample 1:
```in
eight hundred and twenty-one thousand nine hundred and ninety-nine trillion and fifty-two billion thirty-nine million five hundred and seventy-four thousand four hundred and twenty-two
nineteen million nine hundred and ninety thousand five hundred and twenty
```
###Output sample 1:
```out
two
```
###Input sample 2:
```in
881994082555083527588321827035
nineteen million nine hundred and forty thousand eight hundred and twenty-five
```
###Output sample 2:
```out
two
```
###Input sample 3:
```in
one hundred and forty-one million five hundred and ninety-two thousand six hundred and fifty-three
two hundred and sixty-four
```
###Output sample 3:
```out
-1
```






answer:If there is no answer, please comment