BOJ - 15829 - Hashing

Updated:

def solution():
    L = int(input())
    string = input()
    
    ret = 0
    for i in range(L):
        ret += (ord(string[i]) - 96) * (31 ** i)  
    print(ret % 1234567891)

solution()

https://www.acmicpc.net/problem/title : BOJ - 15829 - 인생 점수

Categories:

Updated:

Leave a comment