#A. 约分子串

    Type: Default 1000ms 256MiB

约分子串

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

辰辰发明了一种神奇的运算。

Description

对于两个字符串 p,qp,q,约定 pq\dfrac{p}{q}ppqq 的起始位置,从 11 开始计算。

特别的,如果 pp 中没有 qqpq=1\dfrac{p}{q}=-1

Input

给定一行两个字符串 p,qp,q

Output

输出一个数,代表 pq\dfrac{p}{q}

Samples

aa bb
-1

Limitation

对于 100%100\% 的数据,1p,q1051\le |p|,|q| \le 10^5p×q105×5|p|\times|q|\le 10^5\times 5

提示:[L,R][L,R] 区间里有 rl+1r-l+1 个字符。

[北辰杯 North-Star-Cup] 八月月赛

Not Attended
Status
Done
Rule
Ledo
Problem
6
Start at
2023-8-18 18:00
End at
2023-8-19 0:00
Duration
6 hour(s)
Host
Partic.
98