• Home
  • About
    • JOOS photo

      JOOS

      Joos's blog

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

[hacker_rank] Sam and substrings with python3

07 Mar 2019

Reading time ~1 minute

제 블로그의 모든 글은 IMHO로 쓴 것입니다. 잘못된 부분이 있으면 덧글을 통해서 소통을 하면 더 좋은 글로 발전이 될 수 있을 것 같습니다. 그렇지만 소통을 할 때 서로의 감정을 존중하는 선에서 해주셨으면 좋겠습니다. 감사합니다:)

문제 : https://www.hackerrank.com/challenges/sam-and-substrings/problem


n = input()

ans = 0
mod = 10**9+7

multiply = 1
for i in range(0,len(n))[::-1]:
    ans +=  int(n[i]) * multiply *(i+1)
    ans %= mod
    multiply = (10*multiply+1)%mod    # # 각자리수 하나를 뺀다.
print(ans)



algorithmhacker_rankpython Share Tweet +1