268일차 - BOJ no.15829

https://www.acmicpc.net/problem/15829

My Solution

import sys

L = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()

result = 0

for i in range(L):
    result += (ord(s[i])-96) * (31 ** i)

print(result % 1234567891)

좋은 웹페이지 즐겨찾기