当前位置:网站首页>Openjudge: find all substring positions
Openjudge: find all substring positions
2022-07-28 05:36:00 【Programmer system】
describe
Enter two strings s1,s2, find s2 stay s1 All the places that appear in
The appearance of two substrings cannot overlap . for example 'aa' stay aaaa The only place in the 0,2
Input
The first line is an integer n
Next there is n That's ok , Two strings without spaces on each line s1,s2
Output
For each line , From small to large output s2 stay s1 All the positions in . Location slave 0 Start counting
If s2 It didn't show up , Output "no"
It doesn't matter to output more spaces at the end of the line
The sample input
4 ababcdefgabdefab ab aaaaaaaaa a aaaaaaaaa aaa 112123323 a
Sample output
0 2 9 14 0 1 2 3 4 5 6 7 8 0 3 6 no
Code
n = int(input())
for i in range(n):
s = input().split()
m = 0
if s[1] not in s[0]:
print('no', end='')
for j in s[0]:
a = s[0].find(s[1],m)
if a == -1:
continue
else:
m = a + len(s[1])
print(a,'',end='')
print("") # Each loop wrap 边栏推荐
- 多系统架构设计思考
- MySQL basic query
- 框架一步一步方便使用的流程
- LocalDateTime去掉T,JSONField失效
- 论文模型主图范例
- JUC笔记
- Redis' bloom filter
- Scope, execution process and life cycle of bean
- How about ink cloud?
- Writing methods of scientific research papers: add analysis and discussion in the method part to explain their contributions and differences
猜你喜欢

正则表达式

Digital twin solutions inject new momentum into the construction of chemical parks

Redis' bloom filter

21 day SQL punch in summary

ByteBuffer. Position throws exception illegalargumentexception

论文写作用词

Test Development - UI testing in automated testing

restFul接口使用个人总结

Digital twin technology creates visual application of smart mine

MySQL practice 45 lectures
随机推荐
正则表达式
Oracle用sql查询某张表的字段信息(字段类型、长度等)
When SQL queries the list, the data is inconsistent twice, and limit is automatically added
JVM note 4: Memory Model
Personal summary of restful interface use
数据库面试
【MySQL】MySQL时区问题、数据库时间相差8小时问题解决
Multi module packaging: package: XXX does not exist
latex使用\hl进行高亮时遇到引用总是报错,显示少了括号或者多了括号
block yandex bot
个人写的一个文件上传工具网站
使用navicat或plsql导出csv格式,超过15位数字后面变成000(E+19)的问题
Tomato timing dimming table lamp touch chip-dlt8t10s-jericho
论文模型主图范例
多系统架构设计思考
Image enhancement - msrcr
BigDecimal 进行四舍五入 四舍六入和保留两位小数
PyTorch 使用 MaxPool 实现图像的膨胀和腐蚀
2022 summer practice (PowerDesigner tutorial learning record) (first week)
深度学习医学图像模型复现