题解 | #挑7#

挑7

https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b?tpId=37&tqId=21278&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

import sys


'''
先将s转化为字符串,然后遍历字符串
'''

s =int(input())
def select7(s):
    '''
    当7在i中,或者i能被7整除,将i添加到L中
    '''
    i=1
    L=[]
    while i <= s:
        if "7" in str(i) or i%7==0 :
            L.append(i)
        else:
            pass
        i+=1
    print(len(L))
    return 0

#调用select7函数
select7(s)

全部评论

相关推荐

未知的命运:大佬这都找不到我还找啥啊
点赞 评论 收藏
分享
昨天 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务