如何在WhiteSpace中检查一个字符串是否是另一个字符串的子字符串? [英] How to check whether a string is substring of another in WhiteSpace?

查看:33
本文介绍了如何在WhiteSpace中检查一个字符串是否是另一个字符串的子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我看到这个 SBStr1 时,我正在解决 SPOJ 上的问题.我学习了一点 WhiteSpace 语言,但我只能达到循环.
任何人都可以帮助我如何检查一个字符串是否有另一个字符串作为 WhiteSpace 中的子字符串?

I was going through problems on SPOJ, when I saw this SBStr1. I learnt a little bit of WhiteSpace language, but I could reach only up to loops.
Can anyone please help me on how to check if a string has another string as a substring in WhiteSpace ?

推荐答案

我不会为您编写 Whitespace 代码,但这里有一种您可以轻松转换为 Whitespace 的方法:

I'm not going to write the Whitespace code for you but here is an approach you can take that easily translates to Whitespace:

24 times:
    read 10 bit number into A
    skip space
    read 5 bit number into B
    skip newline

    if (A>>0)%32 == B or (A>>1)%32 == B or ... or (A>>5)%32:
        print 1
    else:
        print 0
    print newline

您可以通过重复除以 2 来实现位移.

You can implement the bitshifts through repeated division by 2.

这篇关于如何在WhiteSpace中检查一个字符串是否是另一个字符串的子字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆