알고리즘

[백준] 27970 | OX [파이썬/python]

사용할수없는닉네임이왜이렇게많지ㅠㅠ 2025. 8. 28. 21:50
728x90

문제

link: https://www.acmicpc.net/problem/27970

 

접근

규칙성만 찾는다면 쉽게 풀 수 있는 문제이다.

 

코드

n = 10**9+7
s = input().rstrip()
x = 1
ans = 0
for a in s:
    if a == 'O':
        ans = (ans + x) % n
    x = (x * 2) % n
    
print(ans)
728x90