[HackerRank][Python3] Sam and substrings
2018. 6. 6. 02:25 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/sam-and-substrings/problem
My Solution :
#!/usr/bin/env python3
def substrings(n):
m = 10**9 + 7
dp = [int(n[0])]
for i in range(1, len(n)):
s = ((i+1)*int(n[i]) + 10*dp[i-1]) % m
dp.append(s)
ret = 0
for s in dp:
ret = (ret + s) % m
return ret
n = input().strip()
result = substrings(n)
print(result)
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] Candies (0) | 2018.06.14 |
|---|---|
| [HackerRank][Python3] Two Characters (0) | 2018.06.11 |
| [HackerRank][Python3] Append and Delete (0) | 2018.06.10 |
| [HackerRank][Python3] Recursive Digit Sum (0) | 2018.06.07 |
| [HackerRank][Python3] Marc's Cakewalk (0) | 2018.06.06 |
| [HackerRank][Python3] Minimum Loss (0) | 2018.06.05 |
| [HackerRank][Python3] Strong Password (0) | 2018.06.05 |
| [HackerRank][Python3] Climbing the Leaderboard (0) | 2018.06.01 |
최근에 달린 댓글 최근에 달린 댓글